Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The following command gives me in the pager Most/Less

man -k background

alt text

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"
share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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