Make emacs run in console mode (-nw) by default

How can I make Emacs run in terminal (or console) mode by default, as if I'd used -nw? And once that's done, how do I force it to run in GUI mode (once) if I need to?


Solution 1:

On my Debian testing, alias emacs='emacs -nw' followed by emacs opens Emacs in the terminal. And, in the same session, emacs23-x opens Emacs with the GUI.

Solution 2:

In case you decide to use emacs in terminal mode always, install emacs-nox (emacs with no X support).

After installationis still ran by $ emacs so you no need to create aliases again!:)

Its there in repos of Debian Squeeze so must be in Ubuntu also.

Solution 3:

This answer suggests the method I found works best for me (was having problems with aliases). Essentially, create an executable script

#!/bin/sh
emacs -nw "$@"

and point $EDITOR to it in your shell rc file.

Solution 4:

I ran into this problem and didn't want to set an alias (because I also wanted "emacs -nw" to be my default shell EDITOR but it wouldn't work) so I started grepping around and saw this line in configure

If you are sure you want Emacs compiled without X window support, pass
--without-x to configure.

So, if you want to download and build from source, you can just do

curl http://gnu.mirrors.hoobly.com/emacs/emacs-25.3.tar.xz
tar -xvzf emacs-25.3.tar.xz && cd emacs-25.3
./configure --without-x
make && sudo make install

Solution 5:

alias emacs='emacs -nw'

Or

unset DISPLAY