Man page highlight color

colorshighlightingless

To colorize my man pages, I put this code from archlinux.org into .bashrc:

man() {
    env LESS_TERMCAP_mb=$'\E[01;31m' \
    LESS_TERMCAP_md=$'\E[01;38;5;74m' \
    LESS_TERMCAP_me=$'\E[0m' \
    LESS_TERMCAP_se=$'\E[0m' \
    LESS_TERMCAP_so=$'\E[38;5;246m' \
    LESS_TERMCAP_ue=$'\E[0m' \
    LESS_TERMCAP_us=$'\E[04;38;5;146m' \
    man "$@"
}

It works okay, except when I search with /, the matches change colors to be even more obscure — the opposite of highlighted. I spent some time trying to figure this out, but I can't really make sense of it, so if I do anything, it'll just be trial and error. Better to ask the experts. So how can I get search matches to be, say, black on yellow, please?

Best Answer

Search patterns in less are colorize according to standout mode setting, so in order to display black on yellow you need to put

export LESS_TERMCAP_so=$'\E[30;43m'

where 30 means black foreground, and 43 yellow background.

Related Question