3

Is it possible, and if so how, to have colour/bold/italic characters in man pages while using w3m?

Another pager (most) does have some limited colour support but is not as versatile as w3m. I know that less does have colour support as shown here.

  • 2
    May depend on the man implementation you use. man from the mandb package has a --html switch. When using it $BROWSER is used for paging instead of $MANPAGER or $PAGER. – manatwork Dec 4 '13 at 11:15
  • @manatwork: I did not know that. This is quiet nice but still no colours... I feel that I should up vote your contribution! ^_~ – Sardathrion Dec 4 '13 at 11:56
  • The man pages will still be formatted with bold and italic. Try lynx. It colors bold in red and italic in blue. (Not sure, but I think those are configurable.) BROWSER=lynx man -H man: i.stack.imgur.com/zIRaw.png – manatwork Dec 4 '13 at 12:30
  • 1
    The colors are configurable; go to O)ptions, scroll to the bottom to where it says "View the file lynx.cfg" -> "color-style configuration". Except you can't edit lynx.cfg in lynx, lol. The system wide is /etc/lynx.cfg. @manatwork : You should put this up as an answer, it's great. – goldilocks Dec 4 '13 at 13:13
  • 3
    How is this not colour support in less? – jasonwryan Dec 4 '13 at 16:26
3

Not quite the answer you were looking for, but it might be a better one.

mandb is an implementation of man that will format man pages in HTML. It was written by someone at Redhat and is I think now the standard on all .rpm based systems, but available to install as a replacement for the old man on Debian, Ubuntu, et. al.

Using mandb, man -H whatever will format the page in HTML and send it to $BROWSER. There are a few man pages where this goes screwy (such as gcc), but most of them are fine. It's also sometimes problematic with google-chrome.

That's a great feature, but most of the time I can't be bothered -- I'd rather just glance through the page in a terminal. Thanks to lynx, a text mode web browser, you can sort of get the best of both worlds. I don't want $BROWSER to be lynx generally, so:

#!/bin/bash

BROWSER=lynx
man -H $@

And call this mnlx or something. mandb creates a tmp file to do this, so you could speed things up by caching the HTML versions and using those when available -- but that's a longer script...

The really nice thing about this is mandb also adds an index with links to each section at the top, e.g.:

                           BASH                BASH (p1 of 121)
   NAME
   SYNOPSIS
   COPYRIGHT
   DESCRIPTION
   OPTIONS
   ARGUMENTS
   INVOCATION
   DEFINITIONS
   RESERVED WORDS
   SHELL GRAMMAR
   COMMENTS
   QUOTING
   PARAMETERS
   EXPANSION
   REDIRECTION
   ALIASES
   FUNCTIONS
   [...]

The man page proper follows this. As manatwork indicates in the comments, italic and bold appear as red and (bold) blue in lynx; normal text is white, links are green, the current link is bold yellow.

  • +1. Not the direct answer to my question but still a great answer to my problem! Thank you. – Sardathrion Dec 4 '13 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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