I find running the following is different from just running emacs on mac

/Applications/Emacs.app/Contents/MacOS/Emacs -nw

Should I create an alias in zsh/bash for it?

  • 2
    I open the Emacs.app just like any ordinary mac apps via Dock, Launchpad, Spotlight etc. I don't use Emacs inside a terminal. The builtin /usr/bin/emacs is too old. Feel free to create an alias for it.
    – xuchunyang
    Nov 9, 2019 at 16:25

5 Answers 5


Just to expand on @ghoetker's answer:

  1. Install Emacs into your application folder from https://emacsformacosx.com/
  2. Using the terminal, open the file ~/.zshrc in your favorite text editor.
  3. Somewhere near the bottom of the file, add the line: alias emacs='$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@")'
  4. Restart the terminal, or type source ~/.zshrc

From now on, typing emacs will open up Emacs in the Finder.

Edit: to cover some questions that have come up, the link in this answer is only one source for Emacs, and there are dozens of others. Anywhere you download it from you will need to take the proper precautions to make sure it's being downloaded from a safe source. How exactly to do that is beyond the scope of this question but if anyone has a particular problem please post it and I'll do what I can to help.

  • Thank you. Is there a way to make it not block the terminal itself? So I would like it to open Emacs on its own separate window, and the terminal prompt to return without me having to close Emacs first , if possible.
    – a06e
    Oct 7, 2022 at 15:01
  • I think you're getting a bit outside the bounds of what the Terminal is able to do there, as you're literally running the program on top of shell instance you're looking at in the Terminal. You can always cmd-shift-t to open a new tab, look for a library like xdotool that will let you run keyboard commands from the shell, program macros into the Terminal itself, etc. But Unix doesn't really have the equivalent of a "multi-finder," if that's what you mean. You can also open a new shell within emacs itself: esc-x "shell."
    – Raydot
    Oct 7, 2022 at 17:09
  • Have you seen MacVim (macvim-dev.github.io/macvim)? When you start it from the terminal (mvim), it opens in a new window and the shell returns immediately.
    – a06e
    Oct 7, 2022 at 20:55
  • Right, that's a "standalone" version of MacVim which runs as a desktop application. I haven't tried but I'm guessing you can download a similar version of emacs, and then add an alias to your shell as ghoetker suggests below. What I'm saying is this doesn't really have as much to do with emacs itself as it does with your emacs and Terminal environments and how you have them set up. Also, check out iTerm2, which is Terminal on steroids!
    – Raydot
    Oct 7, 2022 at 23:16
  • ...and most people use emacs so they don't have to leave the Terminal.
    – Raydot
    Oct 7, 2022 at 23:27

Yes. An alias to the binary within Emacs.app is useful and will allow to call an up-to-date version of emacs from the terminal via “emacs”. I have the following set up

alias emacs='$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@")'
  • How do I enable the -nw option when I want to open emacs within the terminal? Apr 23, 2021 at 18:42
  • Why do you need $@?
    – a06e
    Oct 7, 2022 at 15:03

Applying Dave Kanter's recipe, I still run into trouble: "Emacs" can't be opened because Apple cannot check it for malicious software.

To get it to run, I had to open Settings, Settings, Security & Privacy, General tab and there give Emacs permission to open anyway, at my own risk.

Now I can run Emacs from the command line, albeit without options or arguments (no file name, no -nw option...).

  • 1
    To solve the issue "Emacs" can't be opened because Apple cannot check it for malicious software, see also this answer: emacs.stackexchange.com/a/69444/25843 Nov 23, 2021 at 19:23
  • The problem there is where you get your Emacs from. You will have to get a version that can be verified, or do the verification yourself before you try to install -- the same grain of salt with which you should take pretty much anything you download from the internet. I found a more comprehensive list of links at emacswiki.org/emacs/EmacsForMacOS , same caveat though.
    – Raydot
    Dec 1, 2021 at 20:10

I initially used:

alias emacs='$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@")'

allowing me to open Emacs from terminal but not in it even if I used emacs -nw

After finding I couldn't open Emacs to run in terminal, I replaced the original alias in my .zshrc with:

alias emacs='$(/Applications/Emacs.app/Contents/MacOS/Emacs -nw)'

Now, if I want the gui version I open Emacs using spotlight. If I want the terminal version, I type "emacs" in terminal providing the best of both worlds. With the original line using "$@" I couldn't get Emacs to run in terminal even using "emacs -nw"


Assuming you've downloaded the Mac app to your Applications folder (you can get it from https://emacsformacosx.com/) you can just alias the binary in the app bundle.

In your .zshrc:

alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs -nw'

The -nw/--no-window-system option tells emacs not to use the window system, i.e. run in terminal mode which is what I prefer.

If you prefer to use the GUI interface, you'll probably want to run emacs in the background. Appending & to the end of your command tells your shell to run the command in the background.

In your .zshrc:

alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs'

In the terminal:

emacs my-file.txt &

Aside: Modern OS X installations seem to come with mg (comes from "Micro Gnu emacs") which is a tiny binary with that familiar emacs interface. If you're just doing barebones text file editing, you don't even need to get an emacs binary. You can either use mg directly, or if your muscle memory is too strong:

alias emacs=mg

(I'm not sure what the extra stuff in Raydot's answer is trying to do, but AFAICT it prevents command line arguments from making it to emacs which makes it a not very useful alias for use on the command line)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.