fallback to standard emacsclient if rtramp cannot find tunneled emacs

this also checks to make sure you are in an ssh session, since it
needs the ssh connection information to form the tramp line anyways

for this to properly detect the tunnel being severed, you must set
StreamLocalBindUnlink to yes in your sshd_config, which will delete
("unlink") the unix socket after the ssh session closes
This commit is contained in:
vulpine 2022-06-04 22:40:50 -04:00
parent 0c0470ec49
commit 65826ac3c6
1 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,10 @@
#!/bin/sh
for fn in "$@"; do
real=$(realpath "$fn" || echo "$fn")
printf "/ssh:%s@%s:%s\0" "$USER" "$(echo $SSH_CONNECTION | cut -d' ' -f3-4 | tr ' ' '#')" "$real"
done | xargs -0 emacsclient -s ~/.sshemacs
if [ -S ~/.sshemacs -a -n "$SSH_CONNECTION" ]; then
for fn in "$@"; do
real=$(realpath "$fn" || echo "$fn")
printf "/ssh:%s@%s:%s\0" "$USER" "$(echo $SSH_CONNECTION | cut -d' ' -f3-4 | tr ' ' '#')" "$real"
done | xargs -0 emacsclient -s ~/.sshemacs
else
emacsclient "$@"
fi