How to launch emacs GUI on OS X

Posted on

QUESTION :

Does anyone know any tricks for launching emacs with GUI on OS X with the standard command emacs?

I’m a ten year Linux user and thought I would buy a Mac for a while to stay diverse. I can open files via emacs now with open file.txt, but that wont allow me to use debugging mode.

ANSWER :

You could create an alias such as:
alias emacs = "open -a ProgramName"

If the following is within your realm of expertise it may be worth doing:

  1. Create a directory under /Users/Fred, for instance, /Users/Fred/bin where you store your own executable programs.

  2. Ensure that MacOS knows about your executable directory at login by editing the settings in ~/.MacOS/environment.plist .

  3. Create a file called ~/bin/emacs . In it put the lines

    #!/bin/sh
    exec /Applications/Emacs.app/Contents/MacOS/Emacs $* 
    
  4. Ensure that the file has execute permission: chmod a+x ~/bin/emacs

  5. Depending on your success with 2 (and whether or not you have logged out and in) you should be able to execute emacs with either just emacs or [worst case] with ~/bin/emacs

  6. The advantage of this approach over using open is that you can now use command lines like sudo emacs --user Fred /etc/something-owned-by-root. The --user Fred being useful if you have heavily customized emacs.

Are you using bash? With this bash function definition in your .bashrc (or whatever file you source your bash aliases from), ’emacs <stuff more stuff>’ will do what you expect, including leaving your terminal back at the prompt immediately after launching emacs.

emacs() { /Applications/Emacs.app/Contents/MacOS/Emacs "$@" & }

Have you tried Aquamacs? It has command-line kit, and then you can use it from the command line.

Leave a Reply

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