Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Linux Planet
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tips







Colorizing the Linux Command Line
A Little Color for Readability

Juliet Kemp
Tuesday, August 11, 2009 01:21:35 PM

Juliet Kemp

I find that a little color on the command line helps make things easier to read. ls is easy to colorize: just add the line:

alias ls='ls --color=auto'

in your ~/.bashrc (then source it or open another terminal).

You can also set color up for your manpages. The easiest way to do this is using most as a pager: Install the most package, and then type

export MANPAGER="/usr/bin/most -s"

Try looking at a man page and you'll suddenly see it in color! However, most isn't as good as less as a pager, and if you're accustomed to less you don't necessarily want to retrain your fingers to new commands. An alternative is to set up assorted termcap-related environment variables to provide colors. Add these lines to your .bashrc:

export LESS_TERMCAP_mb=$'E'01;31m'
export LESS_TERMCAP_md=$'E'01;31m'
export LESS_TERMCAP_me=$'E'0m'
export LESS_TERMCAP_se=$'E'0m'
export LESS_TERMCAP_so=$'E'01;44;33m'
export LESS_TERMCAP_ue=$'E'0m'
export LESS_TERMCAP_us=$'E'01;32m'

(with thanks to the CLUG wiki, which also has some other tips). Source your ~/.bashrc and type export MANPAGER="less" to clear the most setting (or just open a new terminal window) and take a look at a man page.

Note: not all systems automatically source ~/.bashrc on login. If you're having problems, trying manually sourcing ~/.bashrc, and if that works, add a line

source ~/.bashrc

to your ~/.bash_profile.

Finally, you can install the package grc to provide color for certain commands (check /etc/grc.conf to confirm which ones -- you can also add your own definitions here). Use it like this:

grc diff file1 file2

Although in the case of diff, a better solution may be to use vimdiff or gvimdiff, both of which provide colors by default and also puts the files side-by-side in a much easier to read format.

Follow ServerWatch on Twitter

Article courtesy of Serverwatch





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers