I have a local environment which is MacOS Catalina and a remote environment which is standard Linux. I use tramp to connect to the remote linux machine to work on it.

Unfortunately, Catalina now defaults to zshell (/bin/zsh) and the linux is standard bash (/bin/bash)

Depending on how I configure my .emacs file, when I invoke M-x shell, it either will default to bash or zshell regardless of the environment. I've tried multiple fixes so that emacs defaults to bash on linux and zshell on macos. The current .emacs I have so far, based on the tramp manual, looks like this:

(defun connect-my-linux-host ()
  (dired "/scp:myname@my-linux-host-url:~"))

(add-to-list 'tramp-connection-properties
             (list (regexp-quote "/scp:myname@my-linux-host-url:")
                   "remote-shell" "/bin/bash"))

 '((explicit-shell-file-name . "/bin/bash")))

 '(:application tramp :protocol "scp" :machine "myname@my-linux-host")

The above configuration defaults to zshell in every environment.

What am I doing wrong?

  • What version of Emacs? These connection properties are fairly recent I believe. Have you tried just (setq explicit-shell-file-name “/bin/bash”? Or just setting your Catalina shell to bash? chsh -sh “/bin/bash” – InHarmsWay May 6 at 7:01
  • @InHarmsWay Emacs 26.3. I have thought of setting everything to bash. But the one that ships standard with Mac is apparently old, which might have all sorts of incompatibilities and vulnerabilities. So I'd like to stick with zsh for now. – JasonMond May 6 at 18:17
  • Fair enough, though brew install bash is another option. What about the setq option? – InHarmsWay May 6 at 18:20

Emacs 26.3 knows connection-local variables. Your approach is OK. However, you must set the :user property explicitly, like

 '(:application tramp :protocol "scp" :user "myname" :machine "my-linux-host")
| improve this answer | |
  • Thanks! That worked. You seem to imply there's a better way than "OK". Can you expand? – JasonMond May 8 at 14:45
  • No, I didn't mean something special with "OK". – Michael Albinus May 8 at 17:46

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.