Scenario
I ssh into a bunch of different servers all the time. I would like to set my EDITOR variable on those servers to invoke emacs on my local machine using emacsclient.
This is confounded somewhat because my machine is behind NAT so my host is not remotely addressable. If it was I could tell emacs server to listen publicly, and maybe even get the server to use a consistent auth key and port.
The setup
- A wrapper around ssh to send the configuration to the remote server whenever I start a session there. This script will also add the remote port forward so that emacsclient on the remote host can get back to my machine.
- A script on the remote hosts to invoke emacsclient with the right parameters.
- export EDITOR
The Details
ssh wrapper
Stick this in a script on the local machine and invoke it instead of ssh.
editor scrpt
Put this on the remote machines, marked executable, and export the EDITOR variable to point at it:
EDIT (6/23/10 10:40AM EST): Updated the editor script to include some error checking.
This is all kinds of awesome and exactly what i was looking for. Thank you!
agreed! thanks for the description, this is really really helpful.
i recently started running my shells inside emacs, so i converted your shell and perl scripts to emacs lisp:
http://snarfed.org/emacsclient_in_tramp_remote_shells
[...] got the idea from Using a local emacs+tramp as your EDITOR on remote servers with SSH and emacsclient, but had to make a few modifications to work with my local set [...]