Last active
November 10, 2021 16:34
-
-
Save linktohack/42e5a69bf283f7b022551ad522efb170 to your computer and use it in GitHub Desktop.
Rmate style remote editing with Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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