
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
View Colored Man Pages in Linux
The man pages are important reference pages for any Unix user. But their look and feel is very boring because it is just lines of text with some punctuations. In this article we will see how the different parts of the man pages can be coloured and highlighted. That will make it very easy to follow the instructions in the man pages.
Using most
The most command can be used to display the colour man pages but first we have to install it and then add to our bash profile so that it becomes available in the environment. The below command shows how to install most.
sudo apt install most
Once added we, can append the value into the .bashrc file, so that the profile gets updated and the variable is available in the environment. We refresh the profile using the source command.
export PAGER="most" # Sourve the .profile file. $ source ~/.profile
Next we run the below command to see how coloured man pages appear when we query the man pages with some command.
Man cp
Running the above code gives us the following result −
CP(1) User Commands CP(1) NAME cp - copy files and directories SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. -a, --archive same as -dR --preserve=all --attributes-only don't copy the file data, just the attributes --backup[=CONTROL]
using the TERMCAP variable
Termcap stands for terminal capability database. Located in /etc/termcap, it is an ASCII file that lists the capabilities of many different types of terminals.Programs can read termcap to find the particular escape codes needed to control the visual attributes of the terminal actually in use. We add the below code to .bashrc file.
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'
next we runt the ls command and get the coloured output as below.