Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Last active August 29, 2015 14:11
Show Gist options
  • Save vermiculus/87d499fc43ea0ced393d to your computer and use it in GitHub Desktop.
Save vermiculus/87d499fc43ea0ced393d to your computer and use it in GitHub Desktop.
#! /bin/sh
SERVER_SCRIPT_FILE="/tmp/emacs-get-server.el"
cat <<EOF > $SERVER_SCRIPT_FILE
(require 'server)
(princ (expand-file-name
server-name (if server-use-tcp
server-auth-dir
server-socket-dir)))
EOF
if [ -e `emacs --script $SERVER_SCRIPT_FILE` ]; then
emacsclient $@
else
# start emacs server using emacs --daemon or something similar
fi
@vermiculus
Copy link
Author

From IRC:

Possible tiny issue. If I use an emacsclient to connect then do ctrl+x ctrl+c it would close the gui window the server would stay running? Which then means the next emacsclient will be without gui? A solution to this might just be to make sure that the server stops if I do ctrl+x ctrl+c but I wondered if you might know a better way with your 1337 emacs skills?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment