How do I see colored man pages with standard Unix or Linux less command without installing most paging program for Unix / Linux like oses?
You can use less command, which is a program similar to more), but which allows backward movement in the file as well as forward movement. Edit ~/.bashrc file using a text editor such as vim / vi, enter:
$ vi ~/.bashrc
Append the following code to get coloured manual pages with less command:
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
Save and close the file.
A Note About Colored Man Pages On xterm or rxvt-unicode
If you are using xterm/uxterm or rxvt-unicode edit the ~/.Xresources or ~/.Xdefaults file, enter:$ vi ~/.Xresources
OR
$ vi ~/.Xdefaults
Xterm user add:
rxvt-unicode user add:
*VT100.colorBDMode: true
*VT100.colorBD: red
*VT100.colorULMode: true
*VT100.colorUL: cyan
Save and close the file. Type the following command:
URxvt.colorIT: #87af5f
URxvt.colorBD: #d7d7d7
URxvt.colorUL: #87afd7
$ xrdb -load ~/.Xresources
OR
$ xrdb -load ~/.Xdefaults
To view the man page of grep command, enter:
$ man grep
Sample outputs:
No comments:
Post a Comment