Add the following to your .bashrc
file:
# Emacs config
export ALTERNATE_EDITOR=emacs EDITOR=emacsclient VISUAL=emacsclient
# Set an alias
alias ec="emacsclient"
Add the following to your ~/.config/systemd/user/emacs.service
file:
[Unit]
Description=Emacs: the extensible, self-documenting text editor
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
# Remove the limit in startup timeout, since emacs
# cloning and building all packages can take time
TimeoutStartSec=0
[Install]
WantedBy=default.target
Run the following as a systemd service:
systemctl --user enable emacs
systemctl --user start emacs
systemctl --user stop emacs
systemctl --user disable emacs