Emacs on Mac OS X

carbon-emacs-iconAt work I use a Linux work station a lot, and one of the things I really enjoy is that when I use Emacs from the command line, it opens up the graphical user interface. This, of course, is not the behavior on OS X. Additionally, the version that ships with Mac OS X is woefully out of date (version 22.1.1 at the time of writing).

I decided to do something about it, and grabbed an up-to-date build of Emacs from emacsformacosx.com. By default, it gets installed in /Applications, which will work just fine. It provides a graphical version of Emacs with support for normal Mac OS X short cuts, like command-c, etc.

But, Michael, how does this solve the problem of the Emacs from the command line being out of date? Well, Inside the application bundle is the Emacs executable that can be run from the command line, sans GUI. All you have to do is create an alias with this code (in my case, I made a bash script that resides in my ~/.bin named ’emacs’) with the following code:

    [ -z "$SSH_CONNECTION" ]
    /Applications/Emacs.app/Contents/MacOS/Emacs "$@"
    /Applications/Emacs.app/Contents/MacOS/Emacs -nw "$@"

This makes it so that if the terminal detects that you are running over an SSH (non-graphical) connection, it will run the non-windowed version of Emacs, otherwise it will launch the graphical version. It works just like it does in most Linux distros, and is a real pleasure to use!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.