Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active November 10, 2021 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linktohack/42e5a69bf283f7b022551ad522efb170 to your computer and use it in GitHub Desktop.
Save linktohack/42e5a69bf283f7b022551ad522efb170 to your computer and use it in GitHub Desktop.
Rmate style remote editing with Emacs
(make-network-process :name "rmacs"
:server t
:host 'local
:service 52699
:filter #'(lambda (proc string)
(delete-process proc)
(raise-frame)
(let ((tramp-allow-unsafe-temporary-files t))
(find-file (string-trim string)))))
;; (delete-process "rmacs")
ssh -R 52699:127.0.0.1:52699 user@host # or with RemoteForward directive
# in remote shell or with sshrc
e() {
local HOST="$(echo "$SSH_CONNECTION" | awk '{ print $3 }')"
while [ -n "$1" ]; do
local file="/sshx:$USER@$HOST:$(realpath "$1")"
bash -c "echo $file > /dev/tcp/127.0.0.1/52699"
shift
done
}
# edit a file via local emacs, no server needed!
e path/to/file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment