5

How can I force the man command to not use a pager, and instead output the whole manpage at once and keep all highlighting?

If I use man -P cat or man | cat, I lose highlighting.

quack quixote
  • 42,186
  • 14
  • 105
  • 129
tig
  • 4,624
  • 4
  • 34
  • 49

4 Answers4

8

Long reading of manuals for man, less, groff and grotty finally gave me answer

Highlighting by default is made using backspace sequences: c\bc => bold c, _\bc => underlined c. But if output as is using cat as pager just outputs plain c in both cases. Also blank lines are squeezed, so to do all this, pager must be set to ul | cat -s.

Pager can be set in many ways:

  1. using MANPAGER or PAGER variables (MANPAGER is better as PAGER affects not only man command)

    export MANPAGER='ul | cat -s'
    
  2. in man.conf

    PAGER       ul | cat -s
    
  3. using -P parameter

    cat -P 'ul | cat -s' …
    

    or

    alias man='man -P "ul | cat -s"'
    
tig
  • 4,624
  • 4
  • 34
  • 49
  • 1
    +1, but I only need to use 'ul' as my pager to dump the output to the console with highlighting. I.e. `man -P ul `. Ubuntu 12.04.2. – G-Wiz Jul 17 '13 at 03:52
3

man man

...
    PAGER          A program to use for interactively delivering
                        man's  output  to  the  screen.   If not set,
                        `more -s' is used.  See more(1).

Which means the pager is regulated by PAGER env. variable, Thus just define PAGER as

setenv PAGER cat

and enjoy.

Moisei
  • 141
  • 4
1

Alternatively, there's always the -P switch:

man -P cat foo
amphetamachine
  • 1,668
  • 2
  • 12
  • 15
1

This is not exactly what you want (you won't get the output in the console) but you could generate a dvi file with the content of a manual as explained in man's man:

man -l -Tdvi ./foo.1x.gz > ./foo.1x.dvi

This command will decompress and format the nroff source manual page ./foo.1x.gz into a device independent (dvi) file. The redi‐ rection is necessary as the -T flag causes output to be directed to stdout with no pager. The output could be viewed with a program such as xdvi or further processed into PostScript using a program such as dvips.

I've just tested this and opened the dvi file with evince: the highlighting is not lost.

Pascal Thivent
  • 1,512
  • 8
  • 11