public
Created

Emacs RC script - a script to do Emacs daemonization control

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/bin/bash
 
WHO=$(whoami)
[ "$WHO" != "nferrier" ] && exec su -c "$0 $*" - nferrier
 
EMACS=/home/nferrier/usr/emacs/bin/emacs
 
SERVERNAME=elnode
SOCKETPATH=/tmp/emacs$UID/$SERVERNAME
 
case $1 in
 
start)
${EMACS}client -s $SOCKETPATH -e '(print (emacs-version))'
if [ $? -ne 0 ] ; then $EMACS --daemon=$SERVERNAME ; fi
;;
 
stop)
${EMACS}client -s $SOCKETPATH -e '(print (emacs-version))'
if [ $? -eq 0 ] ; then ${EMACS}client -s $SOCKETPATH -e '(kill-emacs)' *scratch* ; fi
;;
 
status)
if [ ! -S $SOCKETPATH ] ; then exit 1 ; fi
${EMACS}client -s $SOCKETPATH -e '(print (emacs-version))'
;;
 
esac
 
# End

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.