I know you can customize settings or set environmental variables to get emacs to use other shells in shell-mode (1, 2). Is it possible to simply start a shell specifying which shell you want to use interactively?

Like: M-x other-shell RET /path/to/csh RET

Or set up something in your init file to let you use other shells fairly easily without changing the default?


This appears to do the job:

(defun other-shell (explicit-shell-file-name)
  (interactive "f")
  (if (called-interactively-p)
      (call-interactively #'shell)

This relies on shell using the variable explicit-shell-file-name as a first choice of the shell to be used.

It also relies on not using lexical scoping.

  • This works if you don't already have a shell running. But if you do, it switches you to the existing shell. – Tyler Apr 10 '16 at 20:09
  • @Tyler Use a prefix argument to avoid that. No different from the original shell command. – Harald Hanche-Olsen Apr 10 '16 at 20:10
  • To use a prefix when you have helm-M-x bound see this asnwer emacs.stackexchange.com/questions/20299/… – salotz Apr 12 '16 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.