Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open emacs gui/ide from mac terminal?

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.

like image 828
Austin A Avatar asked Aug 21 '13 02:08

Austin A


People also ask

Is Emacs a GUI?

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.

How do I get Emacs on my Macbook?

Emacs can be installed on MacOS using Homebrew. The Emacs for OSX website also provides universal binaries.


2 Answers

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)
like image 109
katspaugh Avatar answered Oct 03 '22 18:10

katspaugh


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 "$@"
like image 8
shosti Avatar answered Oct 03 '22 17:10

shosti