2

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"
HopelessN00b
  • 53,385
  • 32
  • 133
  • 208

1 Answers1

5

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.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148