public
Last active

Use emacsclient for editing remote files by setting this script as EDITOR in the remote machine

  • Download Gist
remote-emacs.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/sh
#
# Use this script as your EDITOR to allow editing remote files with emacsclient.
# Works by connecting to the Emacs machine with SSH and using a suitable tramp prefix.
 
# How to reach this machine from the one that's running Emacs
ME=user@remote-host
 
# How to reach the machine that's running Emacs from this machine
THEY=user@host-running-emacs
 
if [ "${1#/}" != "$1" ]; then
# absolute path
exec ssh $THEY "emacsclient /$ME:$1"
else
# relative path
PWD=$(pwd)
exec ssh $THEY "emacsclient /$ME:$PWD/$1"
fi

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.