How to colorize manpages
I’m surprised I’ve never posted this here before. Turning manpages from monochrome to color is super easy.
There are a few LESS_TERMCAP_* environment variables you can adjust. Here is a list of useful ones to change
1
2
3
4
5
6
7
8
9
10
|
ks make the keypad send commands
ke make the keypad send digits
vb emit visual bell
mb start blink
md start bold
me turn off bold, blink and underline
so start standout (reverse video)
se stop standout
us start underline
ue stop underline
|
I prefer to only set them for man, so I put this little function in my ~/.bashrc
1
2
3
4
5
6
7
8
9
10
|
man () {
LESS_TERMCAP_mb=$(tput setaf 4)\
LESS_TERMCAP_md=$(tput setaf 4;tput bold) \
LESS_TERMCAP_so=$(tput setaf 7;tput setab 4;tput bold) \
LESS_TERMCAP_us=$(tput setaf 6) \
LESS_TERMCAP_me=$(tput sgr0) \
LESS_TERMCAP_se=$(tput sgr0) \
LESS_TERMCAP_ue=$(tput sgr0) \
command man "$@"
}
|