Skip to content

Instantly share code, notes, and snippets.

@nicferrier
Created March 3, 2012 16:14
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 nicferrier/1966843 to your computer and use it in GitHub Desktop.
Save nicferrier/1966843 to your computer and use it in GitHub Desktop.
Emacs RC script - a script to do Emacs daemonization control
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment