emacs and systemd View article history Edit article

Published: , Updated:
Talks about: <a class="post-tag post-tag-emacs" href="/tags/emacs">emacs</a>, and <a class="post-tag post-tag-systemd" href="/tags/systemd">systemd</a>

I like to use emacs to edit files in a terminal. It tends to start a little slow, therefore I’ve created a systemd unit to automatically start the emacs daemon and use aliases to connect to the running daemon. The unit looks like this:

Description=Emacs text editor [%I]
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

ExecStart=/usr/bin/emacs --daemon=%i
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"


Enable it with systemctl --user enable emacs@user and define any number of aliases to make connecting to the emacs daemon easier:

alias e='emacsclient --tty --socket-name=user'
alias vim='emacsclient --tty --socket-name=user'
alias vi='emacsclient --tty --socket-name=user'
alias nano='emacsclient --tty --socket-name=user'
alias ed='emacsclient --tty --socket-name=user'