As we all know that by editing .bashrc we can give less a colorful appearance. However, the 16-color scheme looks a little bit ugly. For example, if I want to use color yellow but don’t want to make it bold, then the result is a darker yellow, which looks like, you know.

256-color feature solves this problem well. At first I was looking at Wikipedia about SGR(Select Graphic Rendition) parameters. However, I didn’t find it until I saw this page:

http://www.frexx.de/xterm-256-notes/

in which the author mentions:

Set the foreground color to index N: \033[38;5;${N}m

Set the background color to index M: \033[48;5;${M}m

38 and 48 are marked as reserved in Wikipedia page with no more details. Well, we’ve found it after all. So add the following line in .bashrc will make a colorful less (and man if you set less as the default MANPAGER) page:

# color man pages for less
export MANPAGER=/bin/less
export LESS_TERMCAP_mb=$'\E[0;34m'      # begin blinking
export LESS_TERMCAP_md=$'\E[1;38;5;10m' # begin bold
export LESS_TERMCAP_me=$'\E[0m'         # end mode
export LESS_TERMCAP_so=$'\E[7;38;5;15m' # begin standout-mode - info box/search result
export LESS_TERMCAP_se=$'\E[0m'         # end standout-mode
export LESS_TERMCAP_us=$'\E[4;38;5;11m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m'         # end underline