3 ms·
TRAMP reuses ssh connections. It's straightforward to configure OpenSSH to reuse its connection, see e.g. https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multipl
by catern 9y ago
TRAMP reuses ssh connections. It's straightforward to configure OpenSSH to reuse its connection, see e.g. https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing and that is what TRAMP does.
>Can you make it work with multiple SSH connections to arbitrary servers, without any per-server configuration?
Certainly, of course. Depending on your level of hackery, you can:
- Make ssh automatically copy an emacsclient wrapper script over which does the correct thing
- Use OpenSSH's Unix socket forwarding on each connection to connect emacsclient to your local Emacs server
- Use https://github.com/magit/with-editor https://github.com/magit/with-editor
I've never bothered, though, because I run all my shells on remote hosts via TRAMP within Emacs, so when I am in a shell, I can just use open the remote files through the normal Emacs keybindings, rather than typing "emacsclient filename". Thanks to with-editor, this also extends automatically to commands invoked on the remote host which run $EDITOR.
>I don’t have any experience with Emacs, but…
It's not surprising. :) You said "using vi over ssh - or any editor - has always struck me as a hack", "is an unpopular opinion". In fact, it's the consensus in Emacs land. :) Though perhaps that doesn't prevent it from being an unpopular opinion, these days. :)