Pages

Monday, September 26, 2011

Enabling color in Linux terminal

If you're like me, you like to have style aide the eye in distinguishing between objects of different types and show you what's important. While I was beginning to get familiar with Linux (Ubuntu only, really), I wanted some color in the terminal/command prompt.



Here's how you do that (this was in Ubuntu 11.04 Natty Narwahl):

  1. Open up the file browser either in the Unity side bar or hit Alt+F2 and type 'nautilus'.
  2. Enable hidden files to be seen by going to menu bar at the top of the screen--View > Show Hidden Files. Or just hit Ctrl+H.
  3. In your home directory, there should be a file called '.bashrc'. Open it with a text editor, like gEdit. (This file has a bunch of configuration parameters for your user profile. One of them is coloring the prompt up.)
  4. Look for the text, '#force_color_prompt=yes' and remove the '#' symbol. (The hash '#' symbol means this line is commented out, or NOT executed.) Mine was on line 40.
  5. Done!
  6. If you already had the terminal open, you'll need to type 'bash', causing the profile to be reloaded, enabling the color.


The default coloring seems pretty good to me, but there's some customizing you can do, just search for it. You basically end up editing the lines that follow the force_color_prompt=yes line. Mine looked like this, 'PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$'.

Good luck.

1 comment: