Skip to content

Instantly share code, notes, and snippets.

@jhrr
Created March 27, 2014 15:11
Show Gist options
  • Save jhrr/9809753 to your computer and use it in GitHub Desktop.
Save jhrr/9809753 to your computer and use it in GitHub Desktop.
some functions for safely killing and restarting the emacs daemon
server_ok() {
emacsclient -a "false" -e "(boundp 'server-process)"
}
function ek {
if [ "t" == "$(server_ok)" ]; then
echo "Shutting down Emacs server"
emacsclient -e '(kill-emacs)'
else
echo "Emacs server not running"
fi
} # shutdown the running emacs daemon if the server-process is bound
# and the server is in a good state
function ers {
if [ "t" == "$(server_ok)" ]; then
echo "Shutting down emacs server..."
emacsclient -e '(kill-emacs)'
echo "Restarting emacs server..."
emacs -u $USER --daemon --eval '(server-start)'
emacsclient --no-wait --create-frame
else
echo "Emacs server not running, cannot restart"
fi
} # safely shutdown and restart the emacs daemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment