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?
5 Answers
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.
-
13or
\emacs
for the X version. This will call the original emacs not the alias. I have three alias,enw='\emacs -nw -name -bg black -fg white -bd ForestGreen'
,emacsx='\emacs -name Editor_Emacs_$USER@$HOST -geometry 80x50 -bg black -fg white -bd ForestGreen'
andemacs='enw'
to make the nw de default one. Mar 1, 2011 at 14:17
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.
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.
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
alias emacs='emacs -nw'
Or
unset DISPLAY
-
1clearing DISPLAY works but it assumes you don't want to run any other X programs. Jan 17, 2016 at 18:18