Reputation: 3138
I'm trying to open files up on emacs outside of the terminal. I prefer a gui/ide environment when I code instead of doing it through a terminal. I initially thought that typing emacs filename.py
would open that file through Emacs.app, however it only allowed me to edit the file through the terminal. When this didn't work, I looked into editing the .profile and .emacs files in my home directory but this was to no avail.
Maybe this is more intuitive than what I've read but I can't seem to figure it out. Any help is appreciated.
Upvotes: 24
Views: 60118
Reputation: 1496
brew doesn't have cask command anymore.
I used brew install emacs
and I can find Emacs app installed in my application directory.
You can also head to https://emacsformacosx.com and download the .dmg file.
Upvotes: 0
Reputation: 2529
The modern way to go about this is by installing Emacs using Homebrew Cask:
brew cask install emacs
Source: this comment by Homebrew project leader Mike McQuaid, which reads:
Cocoa support for Emacs will not be accepted. This is provided by
brew cask install emacs
.
Upvotes: 6
Reputation: 17899
Assuming you have Emacs installed from Homebrew like this:
brew install emacs --with-cocoa
Just type the following command to open Emacs.app from terminal:
open -a Emacs filename.py
If you want all files opened in the same frame, instead of new frames, put this into your .emacs
file:
(setq ns-pop-up-frames nil)
Upvotes: 42
Reputation: 1116
One should link emacs to /Applications if not already done,
brew linkapps emacs
to link the emacs to symlink emacs installed in Cellar. Once symlinked, you can open emacs by
open -a emacs
as already pointed out by @katspaugh
Upvotes: 3
Reputation: 7422
The best way to open files in Emacs from the terminal is the emacsclient
command, which will open the file in your existing Emacs app (preventing startup time). If you're on OSX and you installed Emacs through Homebrew, the emacsclient
binary will already be set up. (In your Emacs config, you have to include (server-start)
somewhere.)
If you actually want to spin up a new GUI app instance instead, you can set up your own shell script and put it in your PATH
somewhere before the existing emacs
binary. It sounds like you're using Homebrew, which sets up the emacs
binary as the following shell script:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs -nw "$@"
The -nw
is what prevents Emacs from opening in GUI mode. You can make your own emacs
shell script and leave out -nw
:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs "$@"
Upvotes: 8
Reputation: 4733
To do what you want, you'd need to find the location of the actual binary contained in Emacs.app, and use that as the command instead of emacs. Most likely, it's at
/path/to/Emacs.app/Contents/MacOS/Emacs
Which, if you have Emacs.app in your Applications folder, as would be typical, would be
/Applications/Emacs.app/Contents/MacOS/Emacs
To set it up with a shorter command to use, you could try adding to your .profile (I don't know what shell you use) the following line, or whatever equivalent it has for your shell (This works for bash and zsh, at least):
alias emacsgui='/Applications/Emacs.app/Contents/MacOS/Emacs'
Upvotes: 6