Better man pages

The linux command line is extremely well documented but unfortunately this
documentation is mostly in the form of man pages which are, unfortunately,
quite difficult to read.

$: man ls

A little syntax highlighting can make a lot of
difference to the readability and there are many ways to achieve this.

The man pages are presented to the user through a pager such as less. The method I prefer
is to install a pager called most

sudo pacman -S most

Then add the following to your $HOME/.bashrc file (or .zshrc etc).

export PAGER="most"

Reload the bash configuration:

. ~/.bashrc

view a man page

$: man ls

If you prefer a different set of colours execute this command to create your
personal configuration file.

cp /usr/share/doc/most/lesskeys.rc ~/.mostrc

The default settings are in this block of text in that file:

% Color settings

color normal lightgray black
color status yellow blue
color underline brightgreen black
color overstrike brightred black

Change these to your personal preferences:

% Color settings

color normal lightgray black
color status black yellow
color underline brightgreen black
color overstrike brightblue black

$: man ls

The most pager is very configurable - see man most :wink:

1 Like

@piquet I like it :slight_smile:
Maybe it’s worth configuring it this way by default in Mabox … What do you think?

Some sort of highlighting would be nice although this is just one of the many ways of achieving the result. Perhaps some sort of interactive script to set the colours would be nice :sunglasses:

I miss j and k keys while using most as pager…

Another way to display colored man pages with less. Source:

vim ~/.bashrc

Add function:

man() {
    LESS_TERMCAP_md=$'\e[01;31m' \
    LESS_TERMCAP_me=$'\e[0m' \
    LESS_TERMCAP_se=$'\e[0m' \
    LESS_TERMCAP_so=$'\e[01;44;33m' \
    LESS_TERMCAP_ue=$'\e[0m' \
    LESS_TERMCAP_us=$'\e[01;32m' \
    command man "$@"
source ~/.bashrc

If you mean like vi keybindings the j and k keys work for me.

from ~/.mostrc

setkey down β€œe”
setkey down β€œE”
setkey down β€œj”
setkey down β€œ^N”
setkey up β€œy”
setkey up β€œ^Y”
setkey up β€œk”
setkey up β€œ^P”

1 Like