IrrationalRose

Emacs launcher Shell Script May 26, 2015

emacsl.sh is a shell script to conveniently manage Emacs in server/client mode.

Emacs launches slowly in ad-hoc mode. Every time you run emacs some.file a new instance of Emacs is launched and it takes a really long time to load all the scripts/plugins/etc before you can actually edit the file.

There is a faster way to use Eamcs. Emacs can be used in server/client mode where the server only need to be launched once (via emacs —daemon) and each client can be launched pretty much instantly (via emacsclient some.file) and connect to the server to do the editing.

However, having to manually keep track of launching/managing Emacs server/client in a terminal and is tedious and in general just isn’t fun.

The way emacsl.sh works is very simple. You can open files with emacsl.sh via:

$ emacsl.sh some.file

… and emacsl.sh will …

  • Check if there is a running instance of Emacs in daemon mode, and if there isn’t then launch one
  • Launch an instance of Emacs client to connect the the daemon from the previous step

Simply put, emacsl.sh ensures the Emacs server is running before launching an Emacs-client to connect to the server, which IMO, is something that should really just be built into Emacs itself.

You can download emacsl.sh from my dotfiles repo.

If you’re looking for an OS X menubar app that not only manages the launching of Emacs server/client but also offers the banefit of OS X integration, checkout my Emacs Launcher Menubar App.