I'm trying to colorize the manual page for better visaul effect, but the setting(export some env variable in .bashrc
) fails to work for man page, and it only work when I push h
to get SUMMARY OF LESS COMMANDS
I put these setting in my .bashrc
file:
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
export PAGER='less'
And in /etc/man_db.conf
, the default setting for man is:
#DEFINE pager less -s
#DEFINE cat cat
#DEFINE tr tr '\255\267\264\327' '\055\157\047\170'
#DEFINE grep grep
#DEFINE troff groff -mandoc
#DEFINE nroff nroff -mandoc
It seems that man
dosen't generate termcap control sequence correctly when invoking troff
. ( or groff
, nroff
? I'm not sure ) Thus the less
pager can't generate the color escape sequence.
Did I get anything wrong? Or is there something I can try to fix this problem?
terminal emultator: xterm
operating system: Fedora 22
(The vocabulary may be odd, English is not my native language, sorry for that)
Here are the screenshot showing this weird situation:
(I can not include image due to low reputation.)
man: no color rendered
help tab in man: color rendered
Thanks for your helps.
I've installed Fedora 22, reproduced your problem and managed to solve it with the following command:
export GROFF_NO_SGR=1
I found the solution here: https://unix.stackexchange.com/questions/6010/colored-man-pages-not-working-on-gentoo