From the terminal
You can find the appropriate path to emacsclient
using type
in your shell (assuming emacsclient -c
works from said shell):
$ type emacsclient
emacsclient is /usr/local/bin/emacsclient
Then we can add the appropriate emacsclient flags (see $ man emacsclient
for details) to open the GUI:
/usr/local/bin/emacsclient -n -c -a ""
From macOS GUI
To launch emacsclient
from eg the Dock or Spotlight, it's easy to use Automator. Automator is built in to macOS.
Choose to make an "Application", then choose "Run Shell Script", and add a modified version of the above call to emacsclient
:
/usr/local/bin/emacsclient -n -c -a "" -- "$@"
Then change "Pass input": use "as arguments" instead of "to stdin".
The added "$@"
is where any optional arguments passed to this shell script will be placed. Here, this allows you to pass a filename to open with emacsclient
. Automator automates passing this filename in when, eg, you click to open a file with the application we've just made. This also allows you to set the application to be the default application for certain file types.
From anywhere, flexibly
Another way to run the above shell command is with skhd
(link). skhd
is far more involved to learn, but ultimately makes it much easier to set up a large number of shell commands with rapid access.
For example, you could make "Ctrl-o" from anywhere in macOS enter a mode you name open_app
, from which you could press "e" to open emacsclient
, "d" to open emacs --debug-init
, "t" to run emacs --adv-timers
, "f" to open Firefox, "F" to open a second Firefox profile, etc.
emacsclient
is a bit buggy: github.com/railwaycat/homebrew-emacsmacport/issues/52 – Goahead