Created
June 22, 2010 21:04
-
-
Save UnwashedMeme/449078 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
#read from emacs server file what port it is currently listening on | |
PORT=`egrep -o '127.0.0.1:([0-9]*)' ~/.emacs.d/server/server | sed 's/127.0.0.1://'` | |
HOST="${@: -1}" | |
echo "Found host '$HOST'" | |
ssh "$HOST" "mkdir -m 700 -p ~/.emacs.d/server" | |
scp -p ~/.emacs.d/server/server $HOST:.emacs.d/server/server | |
#-R : the remote port forward that lets emacsclient talk back | |
#$@ : any other args this script was invoked with should be passed along. | |
ssh -R $PORT:127.0.0.1:$PORT $@ | |
This file contains hidden or 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
#!/bin/sh | |
if [ -n $ALTERNATE_EDITOR ]; then | |
ALTERNATE_EDITOR=nano | |
fi | |
if ! which emacsclient; then | |
echo "no emacsclient" | |
$ALTERNATE_EDITOR "$1" | |
exit | |
fi | |
SERVER_FILE=~/.emacs.d/server/server | |
if ! [ -r "$SERVER_FILE" ]; then | |
echo "No server info file." | |
$ALTERNATE_EDITOR "$1" | |
exit | |
elif ! emacsclient -f ~/.emacs.d/server/server -e "t"; then | |
echo "Connection to emacs failed." | |
rm -f "$SERVER_FILE" | |
$ALTERNATE_EDITOR "$1" | |
exit | |
fi | |
#build the tramp filename | |
case $1 in | |
/*) FN="/`whoami`@`hostname`:$1" ;; | |
*) FN="/`whoami`@`hostname`:`pwd`/$1" ;; | |
esac | |
echo "$FN" | |
#we point it at the file written by the ssh wrapper for port and auth | |
#information | |
emacsclient -f ~/.emacs.d/server/server "$FN" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment