Created
January 22, 2019 19:29
-
-
Save jhrr/fe778a71e4be1bdf0541f709dfc5d81b to your computer and use it in GitHub Desktop.
This file contains 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
# Emacs daemon functions. | |
emacs_server_ok() { | |
emacsclient -a "false" -e "(boundp 'server-process)"; | |
} | |
# Open a file, in the current shell, using the emacs daemon. | |
e() { | |
if [[ "${1}" == '' ]]; then | |
emacsclient --tty . | |
else | |
emacsclient --tty "${1}" | |
fi | |
} | |
# Open a file, in the current shell, using no config or daemon. | |
et() { | |
if [[ "${1}" == '' ]]; then | |
emacs --no-window-system --quick . | |
else | |
emacs --no-window-system --quick "${1}" | |
fi | |
} | |
# Open a file, in the current frame, using the emacs daemon. | |
emc() { | |
if [[ "${1}" == '' ]]; then | |
emacsclient --no-wait . | |
else | |
emacsclient --no-wait "${1}" | |
fi | |
} | |
# Open a file, in a new frame, using the emacs daemon. | |
en() { | |
if [[ "${1}" == '' ]]; then | |
emacsclient --no-wait --create-frame . | |
else | |
emacsclient --no-wait --create-frame "${1}" | |
fi | |
} | |
# Shutdown the running emacs daemon if the server-process is bound | |
# and the server is in a good state. | |
ek() { | |
if [[ "t" == "$(emacs_server_ok)" ]]; then | |
echo "Shutting down the emacs server" | |
emacsclient -e '(kill-emacs)' | |
else | |
err "Error: Emacs server not running" | |
fi | |
} | |
# Safely shutdown and restart the emacs daemon. | |
ers() { | |
if [[ "t" == "$(emacs_server_ok)" ]]; then | |
echo "Shutting down the emacs server..." | |
emacsclient -e '(kill-emacs)' | |
echo "Restarting the emacs server..." | |
emacs -u "${USER}" --daemon --eval '(server-start)' | |
emacsclient --no-wait --create-frame | |
else | |
err "Error: Emacs server not running, cannot restart. Try invoking: 'esd'" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment