Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like to use emacs as my configuration editor, so it is the default for programs like git or cron. So I used

sudo update-alternatives --config editor

And chose emacs24 from the list.

Unlike Vim or nano, this launches emacs as a new gui application, rather than taking over the current terminal window.

Is there a way to make emacs open in the terminal as a configuration editor, or maybe when it is invoked from the command line, but still allow for launching emacs as a stand-alone application from the launcher or dash?

share|improve this question
up vote 3 down vote accepted

Most utilities, including git respect an environment variable named EDITOR which you can set to any editor you want, including options. export EDITOR='emacs -nw' will have them run emacs in non windowed mode.

In the case of emacs, it has a handy server mode you can start with M-x server-start and then run emacsclient as an editor to open a file in the already running emacs instance. This is handy since it allows you to retain access to the emacs kill ring and other features. It also accepts the -nw switch so that it will open a new emacs frame in the terminal window rather than in the gui emacs frame, so it will still look and feel like a text mode emacs session, but still share the kill ring and buffers with the other window(s).

share|improve this answer

From @steeldriver comment:

git config --global core.editor "emacs -nw"
share|improve this answer

You can invoke emacs with the -nw option

      -nw, --no-window-system
              Tell Emacs not to create a graphical frame.  If you  use
              this switch when invoking Emacs from an xterm(1) window,
              display is done in that window.
share|improve this answer
How can I tell programs like git to invoke emacs in this way? – Eric Wilson Oct 1 '13 at 16:39
@EricWilson, export EDITOR='emacs -nw'. Personally I prefer to use emacsclient so that the file opens in my existing gui emacs window. – psusi Oct 1 '13 at 19:00
FWIW I think git has its own configurable editor setting as well, e.g. git config --global core.editor "emacs -nw" – steeldriver Oct 1 '13 at 19:33
@psusi your comment is really the answer to my question (the first sentence). I'd accept it if it were given as an answer. – Eric Wilson Oct 1 '13 at 20:16

You can change this in ~/.gitconfig by adding the following under the section labeled [core]:

        editor = emacs -nw
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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