Add Colors to Your Manpages

I use the manpages a lot. Manpages are a very useful database of information for linux users and developers. The problem with them is that their appearance becomes boring after a while.

I already wrote a post about reading them from firefox, so they’re displayed in a nice way as html pages.

In this post we’ll add colors to the manpages viewed from inside the shell.

First, open your ~/.bashrc file. To open it with gedit you can type:

gedit ~/.bashrc

Now, to the end of this file, append this:

export LESS_TERMCAP_mb=$’\E[01;31m’
export LESS_TERMCAP_md=$’\E[01;34m’
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’

The strange ‘\E[01;32m’ are special strings which tell the shell to change its foreground’s/background’s color (see my previos post about writing with color in a linux shell). You can change them to suite your terminal’s background color.

Now, save your .bashrc file.

As expected from their names, the above variables do not affect the man program directly, but affect ‘less’ program instead. So, in order to complete our task, we should add an alias to our aliases file (If you don’t have an aliases file you can add this to your .bashrc file):

Add this line to your aliases file:

alias man=’man -P less’

This tells the man program to use less as its pager.

That’s it. Now you just to try it. For example, type: man ls

And see the magic ;)


Note: This was originally posted in Tips4Linux.com

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

No related posts.

Tags: , ,

Monday, December 15th, 2008 Linux

3 Comments to Add Colors to Your Manpages

  • mario says:

    sudo apt-get install most

    export PAGER=most

    does the trick as well.

  • Amir Watad says:

    Hey Mario,
    Thank you for your comment. A great tip.
    Thank you.

  • Trackbacks/Pingbacks

  • Полезности для Ubuntu » proft.com.ua [Блог о Web, IT, life] says:

    [...] Расцветка man [...]

  • Leave a Reply

    my email
    my photo
    Hi,
    My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
    I'm a Verification Engineer in Mellanox Technologies Ltd.
    I love Linux, the Command Line and the OpenSource Community.
    I used to write Poems (Arabic) when I was able to find time for this.
    December 2008
    S M T W T F S
    « Nov   Jan »
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
    SEO Powered by Platinum SEO from Techblissonline

    Twitter links powered by Tweet This v1.7.3, a WordPress plugin for Twitter.