1

I created a Mac App launcher for Emacs installed via Homebrew. The technique uses Automator.

The problem with Automator is that a spinning gear goes into the taskbar each time. I'd rather not have to close it every time I start Emacs!

enter image description here

Emacs Wiki

Using Emacs.app from the Dock Create an app that runs a shell script that runs Emacs.app, like this: use Finder to navigate to /Applications and double-click Automator.app. Select the document type “Application” and click “Choose”. In the list on the left, select “Library”. In the next list, find “Run Shell Script” and drag it into the workflow area on the right. In the new shell script, delete the text and replace it with:

cd # Start in my home directory.

Use my environment: echo '/Applications/Emacs.app/Contents/MacOS/Emacs "$@"' | bash --login -s

"$@" Select “Shell: /bin/bash” and “Pass input: as arguments”. Click “File > Save…” and choose a name and location for your new app. For example, you might choose the /Applications directory and name the app “Emacs for Dock.” Don’t replace Emacs.app.

If you like, you can change your new app’s icon to match Emacs.app, like this: select Emacs.app and right-click “Get Info” or press cmd+i. In the info window, select the small icon in the top left corner and copy it (cmd+c). Next, select your new application, get its info, select the small icon and paste (cmd+v).

Drag your new app into the Dock as usual, and you’re good to go.

Your new app does two things that the Dock doesn’t (on Mac OS 10.9). The “cd” command causes emacs to start in your home directory, instead of the root directory “/”. The --login option gives emacs the same environment as an interactive Terminal. In particular, it gives emacs your usual PATH environment variable, so you can run commands in emacs the same as commands in Terminal. An alternative to --login is -i, which sets the environment differently, as described in the

2
  • I used Platypus, which has options (when creating the application) to run in background and/or remain running after initial execution. I also did it with a combination of shell script that runs an applescript. Line 1: #!/bin/sh Line 3: osascript -e 'tell application "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents/MacOS/Emacs" to activate' I did this to achieve workaround for a rare bug that affected my dock becoming unhidden on Snow Leopard.
    – lawlist
    Oct 19, 2014 at 23:48
  • Is this different than doing brew linkapps? Oct 20, 2014 at 5:39

1 Answer 1

0

I spent a few hours trying various ways to do this same thing today, and came up with one that only has one negative side effect: It creates an extra icon for the running emacs on the dock (See Screenshots). This has only been tested on Yosemite.

Note: I got this from https://korewanetadesu.com/emacs-on-os-x.html, though I didn't bother with the client/server setup as I don't need it. It seems to setup the environment like your wiki example does as well, as far as I can tell.

Screenshots here

This is by creating an apple script using Script Editor (found under Applications/Utilities/ for me) containing in your case:

tell application "/usr/local/Cellar/emacs/HEAD/Emacs.app/Contents/MacOS/Emacs" to activate

And then saving it as an application

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .