How-to: Coloured manual pages

February 17, 2021

It’s easy to take a lot of things for granted when you’ve been using them for longer than you can remember. Coloured manual pages is one of those things.

By default, there’s no colours for the manual pages, which can make it more difficult to distinguish parts and sections of the documentation than it has to be.

This is what my manual pages looks like.

If you want to put some colours on your own manual pages; simply add this to your configuration file for your shell:

man() {
    env LESS_TERMCAP_mb=$'\E[01;31m' \
    LESS_TERMCAP_md=$'\E[01;33;5;74m' \
    LESS_TERMCAP_me=$'\E[0m' \
    LESS_TERMCAP_se=$'\E[0m' \
    LESS_TERMCAP_so=$'\E[38;5;246m' \
    LESS_TERMCAP_ue=$'\E[0m' \
    LESS_TERMCAP_us=$'\E[04;39;5;146m' \
    man "$@"

If you want to change the colour of the yellow text, you have to change the value 33 on line 3 and if you want to change the cyan colour, you then have to change the value 36 on line 8.

Here are the codes if you haven’t memorised them:

Colour Code
Black 30
Red 31
Green 32
Yellow 33
Blue 34
Purple 35
Cyan 36
Light Gray 37


No Comments

Use the e-mail form, if you wish to leave feedback for this post. Markdown is supported. [Terms of service]