Colored Manpages

On some linux based distributions this is the default. But some people find that colored terminals are annoying and quite distracting.

I also don't like multicolored pages with every single word in different color, but when reading manpages I find it beneficial if some keywords are highlighted in different color.

OpenBSD doesn't have this 'feature'...and this is fine, because everyone who wants colors is free to add them - and who don't want can stay with the default. That's freedom :-)

By default man(1) displays the manpages with more(1) or less(1). You can define the environment variable PAGER and instruct man(1) and any other program to use another pagination program (see "The easy route" below). If you want only man(1) to use another pager then you can set the variable MANPAGER.

The Easy Route

If you don't care about installing packages you can just replace the pager with a tool called most(1).

# pkg_add most
# export PAGER="most"

The Fun Way

If you don't want to add software to your system you need to add description for displaying the colored manpages to the terminfo database.

First you have to write the sourcefile of the description and then compile this sourcefile with tic(1). To do this as user $HOME/.terminfo must exist.

$ mkdir ~/.terminfo/ && cd ~/.terminfo

Now get the terminfo description (save the following as ~/.terminfo/colorman):

colorman|manpages with color, 
    am, hs, km, mir, msgr, xenl, 
    cols#80, it#8, lines#24, wsl#40, 
    acsc=`aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
    bel=^G, bold=\E[1m\E[31m, clear=\E[H\E[2J, cr=^M, 
    csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
    cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
    cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
    dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
    dsl=\E]0;\007, ed=\E[J, el=\E[K, enacs=\E)0, fsl=^G, 
    home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, 
    is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, kbs=^H, 
    kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
    kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, 
    kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
    kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
    kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, 
    kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
    kfnd=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
    kslt=\E[4~, rc=\E8, rev=\E[7m\E[34m, ri=\EM, rmacs=^O, 
    rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
    rmso=\E[m, rmul=\E[m, 
    rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sc=\E7, 
    sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, 
    smkx=\E[?1h\E=, smso=\E[1;30m\E[47m, smul=\E[32m, 
    tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n, 
    u8=\E[?1;2c, u9=\E[c, 

the description is reconstructed via infocmp(1) from /usr/share/terminfo/x/xterm-pcolor

Now compile it using tic (the terminfo entry-description compiler):

$ tic colorman

And then just define an alias for man:

$ alias man="TERMINFO=~/.terminfo/ TERM=colorman PAGER=less man"