Bash Alias for emacs -nw

Emacs is an awesome text editor with a slightly steep learning curve. However, once you have mastered the basics of emacs your life will change forever.

One little annoying thing that I have found is that when you install emacs in Ubuntu, OS X, and probably a couple other distributions typing in emacs in the terminal will open the emacs GUI. This seems silly to me because the best part about emacs is that it does not require a GUI and runs natively in the terminal. In addition, running emacs in the terminal will force you to learn how to use it, and these skills will come in handy when working on different types of operating systems or in systems that do not have a GUI at all.

In order to get emacs to run in the terminal you must invoke it using the -nw argument which stands for “no window system”. If you wish to automatically open emacs in a terminal rather than in the GUI when you type the emacs command you can simply make a bash alias that changes the meaning of the command.

These are the steps to create a bash alias for emacs -nw:

  1. Open up the .bashrc file from the terminal with your favourite text editor.
    emacs ~/.bashrc</pre>
  2. Add the following line to the bottom of the file
    alias emacs='emacs -nw'</pre>
  3. Save this file, and then reload your bash profile
    source ~/.bashrc</pre>

You should now be able to type in emacs into your terminal and see emacs open inside of the terminal. Yay! Happy Hacking.

If you made it this far, you should probably follow me on twitter. 🙂

This entry was posted in Hacking and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *