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.
Emacs has two versions: the GUI version which runs in a separate window and has buttons and menus for common functions, and the text-based version which runs in your console window.
Emacs can be installed on MacOS using Homebrew. The Emacs for OSX website also provides universal binaries.
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)
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 "$@"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With