Emacs, Tramp and (remote) zsh

I often use Emacs Tramp as a way to remotely connect to other machines while editing with my local Emacs configuration. Essentially, Tramp opens an ssh connection to the remote host allowing me to edit files and moving within the filesystem thanks to dired. I prefer to use zsh as my default shell, and sometimes I forget to configure properly my shell to get Tramp working. It happens, in fact, that when connecting to zsh Tramp hangs. The solution is quite simple and is reported in the Tramp manual: add to the .zshrc on the remote machine a line that prevents the ZLE to fire up when Tramp is opening a connection. The following is the piece of code to place in .zshrc:

```shell [[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return ```


The idea is quite simple: when connecting Tramp sets the TERM variable to dumb, therefore if the terminal is found to be a dumb one the zle is disabled and prompt is changed to something similar to the Bash shell (i.e., $).

The article Emacs, Tramp and (remote) zsh has been posted by Luca Ferrari on February 15, 2024