Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

So I'm on my first day at my new job, and on the server we use, the default emacs is X-windows based. I much prefer using it in the good old terminal, and I'd like to be able to make the command emacs foo.txt be read as emacs --no-window-system foo.txt.

I tried to do this by adding the line function emacs() { emacs --no-window-system "$@" ;} to my ~/.profile, and then ran source ~/.profile, but the system is unresponsive to emacs foo.txt.

Am I doing this wrong? As an alternative, I would like to know if what I want to do is completely backwards, and it turns out that there is a far simpler solution.

share|improve this question
up vote 1 down vote accepted

This would be better as an alias.

Put this in your .profile or .bashrc

alias emacs='emacs -nw'
share|improve this answer
Thanks, unfortunately I'm not getting good results with this either. I tried this in both .profile and .bashrc, ran source .profile or source .bashrc beforehand, and then ran emacs foo.txt, but both times nothing happens until I type Ctrl+D, at which point it returns to the prompt. – Frank Harris Jun 3 '13 at 15:58
@FrankHarris What happens when you just emacs -nw foo.txt? I've never seen an Emacs build which was X-only, but I suppose such a thing is theoretically possible. – Aaron Miller Jun 3 '13 at 16:03
@AaronMiller, the problem has been resolved after I logged out and in again. I was under the impression that source .profile would achieve the same thing, so not sure why it didn't work then! It might've been a completely unrelated error, but the point is that it works now. Thanks for your help! – Frank Harris Jun 3 '13 at 16:20
@AaronMiller I want to vote you up but I'm new and apparently need more reputation. I'll try to remember to do so when I get it; you've been a big help. – Frank Harris Jun 3 '13 at 16:21
@FrankHarris Thanks, and no worries! Glad to be of help. – Aaron Miller Jun 3 '13 at 16:55

I believe that the problem with your original solution is that the call to emacs inside your emacs function is a recursive call to the emacs function. You can call the emacs program instead of your emacs function by using the bash builtin command.

function emacs() { command emacs --no-window-system "$@" ;}

I have kind of the opposite desire: I want to automatically background emacs when I'm running under a window system. I have the following in my .bashrc:

if [ -n "$DISPLAY" ]; then
    function emacs() { (command emacs "$@" &) }
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.