HomeLinuxView or Show Coloured Man Pages in Linux

View or Show Coloured Man Pages in Linux


In Unix-like working methods, a man web page (in full guide web page) is a documentation for a terminal-based program/device/utility (generally referred to as a command). It comprises the title of the command, syntax for utilizing it, an outline, choices accessible, writer, copyright, associated instructions and so on.

You may learn the guide web page for a Linux command as follows; it will show the person web page for the df command:

$ man df 
df Command Man Page
df Command Man Web page

By default, the person program usually makes use of a terminal pager program akin to roughly to format its output, and the default view is often in white coloration for each type of textual content (daring, underlined and so on..).

You may make some tweaks to your ~/.bashrc file to get properly coloured man pages by specifying a coloration scheme utilizing varied LESS_TERMCAP variables.

$ vi ~/.bashrc

Add following coloration scheme variables.

export LESS_TERMCAP_mb=$'e[1;32m'
export LESS_TERMCAP_md=$'e[1;32m'
export LESS_TERMCAP_me=$'e[0m'
export LESS_TERMCAP_se=$'e[0m'
export LESS_TERMCAP_so=$'e[01;33m'
export LESS_TERMCAP_ue=$'e[0m'
export LESS_TERMCAP_us=$'e[1;4;31m'

Following are the color codes that we used in the above configuration.

  • 31 – red
  • 32 – green
  • 33 – yellow

And here are the meanings of the escape codes used in the above configuration.

  • 0 – reset/normal
  • 1 – bold
  • 4 – underlined

You can additionally reset your terminal by typing reset or even start up another shell. Now when you try to view a man page df command, it should look like this, nicer than the default view.

Colored Man Page
Colored Man Page

Alternatively, you can use the MOST paging program, which works on Unix-like operating systems and supports multiple windows and can scroll left and right.

$ sudo apt install most		#Debian/Ubuntu 
# yum install most		#RHEL/CentOS
# dnf install most		#Fedora 22+

Next, add the line below in your ~/.bashrc file, then source the file like before and possibly reset your terminal.

export PAGER="most"
Most Paging Program for Linux
Most Paging Program for Linux

In this article, we showed you how to display beautifully colored man pages in Linux. To send us any queries or share any useful Linux shell tips/tricks, use the comment section below.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments