Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch GUI Emacs from command line in OSX?

How do I launch GUI Emacs from the command line in OSX?

I have downloaded and installed Emacs from http://emacsformacosx.com/.

I'll accept an answer fulfilling all of the following criteria:

  1. The emacs window opens in front of my terminal window.
  2. Typing "emacs" launches a GUI Emacs window. Finding files in that window will default to looking in the directory from where I started Emacs.
  3. Typing "emacs foo.txt" when foo.txt exists launches a GUI Emacs window with foo.txt loaded.
  4. Typing "emacs foo.txt" when foo.txt does not exist launches a GUI Emacs window with an empty text buffer named "foo.txt". Doing ^X^S in that buffer will save foo.txt in the directory from where I started Emacs.
like image 832
Johan Walles Avatar asked Apr 16 '12 09:04

Johan Walles


People also ask

How do I start Emacs in GUI mode?

If you are working with a graphical user interface, start Emacs by clicking its icon or by running emacs & at the command line. The & tells the command line to open Emacs in the background and immediately return control of the terminal to you.

How do I open Emacs from command line?

The Control key is usually labeled 'Control' or 'CTRL' and is held down while typing the other keys of the command. To enter Emacs, type emacs at the shell prompt. When you want to leave Emacs for a short time, type a C-z and Emacs will be suspended. To get back into Emacs, type %emacs at the shell prompt.

How do I get Emacs on my Mac?

Mostly simply, download and run the emacs- version -installer.exe which will install Emacs and create shortcuts for you. Alternately, download emacs- version .


1 Answers

Call the following script "emacs" and put it in your PATH somewhere:

#!/bin/sh /Applications/Emacs.app/Contents/MacOS/Emacs "$@" 

That covers #2, #3, and #4.

For #1, put this somewhere in your .emacs file:

(x-focus-frame nil) 

The emacsformacosx.com site now has a How-To page, which is where the top snippet came from. There's more info there about running emacsclient and hooking Emacs up to git mergetool.

like image 103
David Caldwell Avatar answered Sep 22 '22 18:09

David Caldwell