The following command gives me in the pager Most/Less

man -k background

alt text http://files.getdropbox.com/u/175564/apropos-colors.png

The picture has everything in green, even descriptions. I would like to set them yellow.

How can you have set the descriptions yellow in Less/Most by Less_termcap?

My variables which affect Less

     export LESS_TERMCAP_mb=$'\E[01;31m'         # begin blinking
     export LESS_TERMCAP_md=$'\E[01;38;5;74m'    # bold in blue
     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;33;146m'    # begin underline is now yellow
     #                             |  |  |
     #                             |  |----------------- yellow
     #                             |-------------------- underline

     # to have the indication of cursor's location and line numbers
     export LESS="-mN"

This will do the trick:

man -k background|sed "s/ - \(.*\)/ - \o033[33m\1\o033[0m/"

You could do a function:

mank () { man -k $1|sed "s/ - \(.*\)/ - \o033[33m\1\o033[0m/"; }

Then you could do:

mank background

and the commands would be in your default color and the descriptions would be yellow. The "33" after the square bracket stands for yellow. You can substitute another number for another color. One place to get a list of colors and their codes is man 5 dir_colors.

And, of course, you have to use less -R (or set $LESS to include it) to see the colors in less.

Here is a more portable version that uses tput:

mank() { local yellow=$(tput setaf 3) default=$(tput op); /usr/bin/man -k $1|sed "s/ - \(.*\)/ - ${yellow}\1${default}/"; }

See man tput and man 5 terminfo (in the "Color Handling" section) for more info, including a list of color numbers that setaf understands.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.