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
 emacsclient -nq “$@” &> /dev/null

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?

  • You could add symlinks $HOME/bin/emacs{,client} -> /path/to/abc_emacs{,client}, and put $HOME/bin in your standard PATH.
    – phils
    Mar 9, 2019 at 8:31

1 Answer 1


The option -a specifies the editor that should be started if there is no emacs server started yet (the so-called "alternate editor). If the empty string is passed, as in the script above, emacs --daemon is run and emacsclient tries to connect to it (see man emacsclient or M-: (info "(emacs) emacsclient Options") within emacs). Unfortunately, in your case, emacs --daemon obviously runs the wrong Emacs. Hence, we'd like to specify an alternate editor that will start abc_emacs --daemon and then connect to it. I think the easiest method is to simply create a script that will do that for us.


abc_emacs --daemon
emacsclient "$@"

Call it, say, abc_emacs_helper (hopefully that won't collide with any existing programs), make it executable and place it somewhere in your $PATH. Then you can replace emacsclient -a '' with emacsclient -a 'abc_emacs_helper').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.