create emacs alias that starts in background?
Instead of calling /usr/bin/emacs-snapshot
directly, write a script that calls /usr/bin/emacs-snapshot
in the background and then returns:
#!/bin/shcase $# in 0) /usr/bin/emacs-snapshot & *) /usr/bin/emacs-snapshot "$@" &esac
Then you call the script in the ordinary way; it will launch a background emacs process and return immediately.
If you want to get fancy you can use /bin/bash
and disown
the process after the esac
(get the pid with $!
).
While this is not the direct answer to your question, this is the more elegant way to "start emacs deamon or run emacsclient otherwise". Create the following alias: alias emacs=emacsclient -c -a ""
. As of man emacsclient
:
-a, --alternate-editor=EDITOR ... If the value of EDITOR is the empty string, run `emacs --daemon' to start Emacs in daemon mode, and try to connect to it.