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!No related posts.
3 Comments to Add Colors to Your Manpages
Trackbacks/Pingbacks
[...] Расцветка man [...]
Leave a Reply
About Me
Tags
Categories
- Algorithms
- Bash
- BlackBerry
- Collaboration
- Command Line
- Cool Tricks
- Easter Eggs
- Ebooks
- Firefox
- Hardware
- Humor
- iPhone
- Linux
- Linux Development
- Linux Kernel
- Networks
- Open Knowledge
- Other
- Productivity
- Programming
- Regular Expressions
- Science
- Security
- Shell Scripts
- Short Posts
- Social Networks
- Thoughts
- Tools
- Vim
- Web Development
- Websites
Popular Posts
Calendar
Archives
- September 2010 (1)
- August 2010 (2)
- July 2010 (5)
- June 2010 (1)
- May 2010 (1)
- April 2010 (3)
- March 2010 (1)
- January 2010 (1)
- December 2009 (2)
- September 2009 (13)
- July 2009 (1)
- June 2009 (6)
- May 2009 (4)
- March 2009 (18)
- February 2009 (10)
- January 2009 (10)
- December 2008 (7)
- November 2008 (8)
- October 2008 (1)
- August 2008 (1)
- July 2008 (1)
- June 2008 (2)

sudo apt-get install most
export PAGER=most
does the trick as well.
Hey Mario,
Thank you for your comment. A great tip.
Thank you.