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?

4 Answers 4


From @steeldriver comment:

git config --global core.editor "emacs -nw"

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).


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.
  • How can I tell programs like git to invoke emacs in this way? Oct 1, 2013 at 16:39
  • 1
    @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, 2013 at 19:00
  • 2
    FWIW I think git has its own configurable editor setting as well, e.g. git config --global core.editor "emacs -nw" Oct 1, 2013 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. Oct 1, 2013 at 20:16

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

        editor = emacs -nw

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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