You can use the less command, which is a program similar to more), but which allows backward movement in the file as well as forward movement. Edit ~/.bashrc file using a text editor such as vim / vi, enter:
How to view colored man pages in Linux
Edit the ~/.bashrc, run:
$ vi ~/.bashrc
Append the following code to get coloured manual pages with less command:
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 "$@" }
Save and close the file. Just load your updated ~/.bashrc with the source command:
$ source ~/.bashrc
Test it:
$ man ls
$ man date
$ man 3 printf
A Note About Colored Man Pages On xterm or rxvt-unicode
If you are using xterm/uxterm or rxvt-unicode edit the ~/.Xresources or ~/.Xdefaults file, enter:
$ vi ~/.Xresources
OR
$ vi ~/.Xdefaults
Xterm user add:
*VT100.colorBDMode: true *VT100.colorBD: red *VT100.colorULMode: true *VT100.colorUL: cyan
rxvt-unicode user add:
URxvt.colorIT: #87af5f URxvt.colorBD: #d7d7d7 URxvt.colorUL: #87afd7
Save and close the file. Type the following command:
$ xrdb -load ~/.Xresources
OR
$ xrdb -load ~/.Xdefaults
To view the man page of grep command, enter:
$ man grep
Sample outputs:
- Display Colored Man Pages in Linux and Unix
- Colored Man Pages With less Command
🐧 5 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks for the article.
Just tried it on my home CentOS system through SSH using Putty. It works like a charm under this conditions.
When I get home I’ll try the suggestions under X.
Any chances of having this working under other shells such as tcsh and zsh?
Regards.
Thanks,
i was searching for that. Using most as a pagerviewer is also possible, but i was missing the ‘J’ and ‘K’ key to navigate through the page.
+1
Actually, you can do that by editing (or creating) /etc/conf.conf: https://wiki.archlinux.org/index.php/Man_Page#Using_most_.28Not_recommended.29
/etc/conf.conf > /etc/most.conf