Enhancing the experience of manpages

Enhancing the experience of man pages

Now

Man pages are full of useful information, enhanced with some formatting such as bold and underlined font.

To new users this can appear arcane and off-putting. To experienced users this can still be visually unappealing and tedious.

We can do better.

A colourful future

man uses the MANPAGER environment variable, if set, to send its output to a pager program such as more, less or most. I use less which can be configured to, among other things, display line numbers and augment formatting e.g.

MANPAGER="less -N --use-color -Dd+y -Du+208 -DN+r" man openssl

I find this far more appealing and easier to scan quickly. You may disagree with my colour choices. If you do please free to improve upon them and report back.

Breaking it down:

  • less use the less pager
    • -N display line numbers
    • --use-color display colour in conjunction with -D
    • -Dd+y add yellow colour to text with bold font
    • -Du+208 add colour 208 from the 8-bit colour pallette to underlined text
    • -DN+r colour the line numbers red.

These options can be seen in the man page for less.

There are also termcap options which can be exported to achieve colourful man pages.

What should we do with this knowledge?

I think we should consider whether this would be a good enhancement for the user experience. Exporting the MANPAGER environment variable on behalf of users, desktop and server, is one approach, but adding an alias might be a nice, un-intrusive, alternative.

# File: ~/.bash_aliases

alias manual='MANPAGER="less -XNR --use-color -Dd+y -Du+208 -DN+r" man'

I would like to hear your thoughts, fellow members of the community. Most people seem unaware of the possibility. Perhaps this is something Ubuntu & the flavours would consider adopting and refining for implementation?

Best regards

Daniel

6 Likes

This is a neat idea. A couple of extra thoughts:

It would be nice if these were Ubuntu colours. Annoyingly, the Ubuntu brand colours aren’t exactly available from less’s determinedly 8-bit palette, but we can approximate them; “light aubergine” is fairly close to ANSI colour 89; warm grey fairly close to ANSI 145; and Ubuntu orange fairly close to 202. I’ve always found it rather good that Ubuntu terminals are instantly recognisable in screenshots (and so the OS used to take the screenshot is instantly recognisable as having been Ubuntu), and this would continue that.

It would also be nice to use the long options for the MANPAGER envar (which I’d be in favour of being made a default setting, rather than an alias; branding is good!) so that if someone discovers the MANPAGER envar it is at least a little self-documenting, rather than having to look up all the short options (with man, haha!) to see what -XNR means. Doing both of these things means that the MANPAGER envar would look like

MANPAGER="less --no-init --LINE-NUMBERS --RAW-CONTROL-CHARS --use-color --color=d+89.145 --color=u+202 --color=N+89" man man

image

1 Like

Good points @sil :+1::+1:. The only reason I didn’t suggest Ubuntu colours is because they wouldn’t necessarily work on the terminals provided by the flavours. That said, I think it would make sense for Ubuntu proper to use Ubuntu themed colours, kubuntu to use kubuntu themed colours etc.

Long options are the better approach, of course. Thanks for pointing that out.

I’m very interested to see support for exporting MANPAGER! I thought it would be devisive. We’ll soon see, I hope :slight_smile:

Flavor lead here. Don’t worry about that. All flavors are Ubuntu and not separate distributions.

3 Likes

I only mean to distinguish between the theming of the flavours etc, not to suggest that Kubuntu, Ubuntu Studio, etc are not Ubuntu :slight_smile:

As both a user and a flavour lead, what do you think of the general idea being presented?

I like it. I think it would be nice to have colors for the manpages.

That said, I rarely use manpages unless I need to reference something. That said, a wall of monochromatic text is hard on the eyes.

Consideration also needs to be given to those with colorblindness. What colors provide the most contrast, and how would they be able to change the color theming? I’d posit a simple configuration change would need to be available for accessibility reasons.

1 Like

We could put a brief comment on the preceding line(s) to instruct all users to refer to the Options section of the less man page so they can pick the colours that best suit their usage be it for accessibility reasons or purely aesthetic reasons.

E.g.

# Refer to the OPTIONS section of the `less` manpage
# for colour configuration details
export MANPAGER=...

Right. I’m just not a fan of text configuration files for everything, and I’m also not a fan of encouraging users to live in the terminal. In fact, I’m doing a talk at this year’s Ubuntu Summit that encourages developers to do exactly that: stop developing for themselves and start developing actual GUIs rather than relying on the terminal for everything.

But I digress. It does seem like a decent solution.

1 Like

Great stuff, but Man uses COLUMNS (number of characters fitting the line in the terminal) to calculate line breaks; Adding line numbers with -N to Less causes decreases the number of actually available columns in the terminal, breaking the page and causing much noise with a few characters long lines, as can be seen in the picture in the first reply.

I therefore suggest amending your alias to

alias manual='MANPAGER="less -XNR --line-num-width=4 --use-color -Dd+y -Du+208 -DN+r" COLUMNS=$((COLUMNS-5)) man'
2 Likes

Yes, a very good point.
I set my pager to chop lines instead of wrapping them, so this is not an issue for me.

Enabling either line chopping or setting the columns would be a good addition.

Thanks for the great feedback