I have found this script from here
#!/usr/bin/env zsh
# Checks if there's a frame open
emacsclient -n -e “(if (> (length (frame-list)) 1) ‘t)” 2> /dev/null | grep t &> /dev/null
if [ “$?” -eq “1” ]; then
emacsclient -a ‘’ -nqc “$@” &> /dev/null
else
emacsclient -nq “$@” &> /dev/null
fi
that seems nice for starting the daemon with -a ''
only if there is not a server up. However at my work, our emacs and emacsclient intended to be used are prefixed with abc
, so we have abc_emacs
and abc_emacsclient
. There are older Emacs in the system with the regular names.
So how do I modify a command like emacsclient -a '' -nqc somearg
so that it starts the server in the case of no server being up with abc_emacs
instead of emacs
?
$HOME/bin/emacs{,client} -> /path/to/abc_emacs{,client}
, and put$HOME/bin
in your standard PATH.