Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Where do I have to take a look at in the system to colorize the man pages?

The man pages are viewed with less, so I tried adding the following lines to my .bashrc to change the colors: (Which works fine, btw.)

 #
 #   L E S S   C O L O R S   F O R   M A N   P A G E S
 #

 # CHANGE FIRST NUMBER PAIR FOR COMMAND AND FLAG COLOR
 # currently 0;33 a.k.a. brown, which is dark yellow for me 
    export LESS_TERMCAP_md=$'\E[0;33;5;74m'  # begin bold

 # CHANGE FIRST NUMBER PAIR FOR PARAMETER COLOR
 # currently 0;36 a.k.a. cyan
    export LESS_TERMCAP_us=$'\E[0;36;5;146m' # begin underline

 # don't change anything here
    export LESS_TERMCAP_mb=$'\E[1;31m'       # begin blinking
    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

 #########################################
 # Colorcodes:
 # Black       0;30     Dark Gray     1;30
 # Red         0;31     Light Red     1;31
 # Green       0;32     Light Green   1;32
 # Brown       0;33     Yellow        1;33
 # Blue        0;34     Light Blue    1;34
 # Purple      0;35     Light Purple  1;35
 # Cyan        0;36     Light Cyan    1;36
 # Light Gray  0;37     White         1;37
 #########################################

To my shame I have to admit that I did not find out what the second number pair meant, i.e. the 5;74 and the 5;146.

Can someone clarify that further?

share|improve this question

migrated from stackoverflow.com Jul 22 '12 at 7:05

This question came from our site for professional and enthusiast programmers.

    
What is it with the close votes? I have known the wikipedia link before and still i have no idea what the order of the sequence means. Trial and error and setting different values did not help me at all. A simple "go RTFM" does not help me here. –  sjas Jul 21 '12 at 23:12
    
You gotta be kidding me... this is just great! Where is this stuff documented? I looked in the BASH and LESS man pages but could not find the LESS_TERMCAP string. –  ysap Jan 23 '13 at 8:21
    
OK, found this for starters: unix.stackexchange.com/questions/119/colors-in-man-pages –  ysap Jan 23 '13 at 8:23
    
This: "for name [ [ in [ word ... ] ] ; ] do list ; done" makes more sense now, in color... 8-) –  ysap Jan 23 '13 at 8:28
    
@ysap : Haven't seen that links, and cannot remember where I found this. Put this here for documentation purposes and asked about the escape sequences in the process. :) –  sjas Jan 23 '13 at 9:18

4 Answers 4

up vote 1 down vote accepted
export LESS_TERMCAP_md=$'\E[0;33;5;74m'  # begin bold
export LESS_TERMCAP_us=$'\E[0;36;5;146m' # begin underline

In these two cases, all the colors and attributes are reset (0), the foreground color is switched to yellow/brown (33) or cyan (36), then blinking is turned on (5), and then something else also happens (74 or 146) which are probably undefined and not desired.

export LESS_TERMCAP_so=$'\E[38;5;246m'

This one's different, because 38 takes additional numeric parameters. It stands for extended foreground color (and similarly 48 would be the same for background), and if followed by a 5 as the next parameter (which doesn't have anything to do with blinking this time) the third number specifies the color's index (from 0 to 255: 16 standard legacy colors, followed by a 6x6x6 RGB cube, followed by 24 grayscale colors), see e.g. here.

Certain terminal emulators also support direct arbitrary RGB colors, in that case 38 should be followed by 2, and then by three decimal numbers in the 0-255 range for R, G, B respectively, e.g. #BADA55 is

\E[38;2;186;218;85m
share|improve this answer
1  
It's quite bad that you can't know which ; stands for additional parameters of a previous one and which stands for a brand new without looking at the exact numbers. So it was recommended that additional parameters should be separated by a : instead. For example, to reset everything, then switch to color #246, and also turn on blinking, instead of 0;38;5;246;5 you'd say 0;38:5:246;5. Unfortunately it's supported by even fewer terminals. –  egmont Apr 25 at 22:38

"\e[...m" is the SGR CSI code. The Wikipedia page on "ANSI escape code", "CSI codes" section describes them.

share|improve this answer

With the help of http://invisible-island.net/xterm/ctlseqs/ctlseqs.html and the wikipedia link I came to the conclusion that 5 means 5 Blink: Slow less than 150 per minute.

The last numbers sound like this:

 If 88- or 256-color support is compiled, the following apply. 
 P s = 3 8 ; 5 ; P s → Set foreground color to the second P s . 
 P s = 4 8 ; 5 ; P s → Set background color to the second P s .

Also it seems that the amount of numbers is not important, just their chronological order.

share|improve this answer

Not exactly a bash solution, but still relevant, use:

PAGER=~/bin/vimpager

and drop this into ~/bin: https://github.com/rkitover/vimpager

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.