Linux / Unix Colored Man Pages With less Command

You can use the less command to view man pages with color in a Linux or Unix system. By default, the less command does not display man pages with color, but you can enable color with the LESS_TERMCAP_md environment variable.

Here’s an example of how to view man pages with color using the less command:

export LESS_TERMCAP_md=$'\e[01;31m'
man <command> | less

Where <command> is the name of the command you want to view the man page for.

In this example, we’re setting the LESS_TERMCAP_md environment variable to set the color of the text displayed by less to red (\e[01;31m).

You can also add this line to your shell profile file (e.g., ~/.bashrc, ~/.bash_profile, or ~/.zshrc) to make the change permanent.

Note that the color escape sequences used in the LESS_TERMCAP_md environment variable may vary depending on your terminal and terminal emulator. You can use different escape sequences to change the color to any color you want.

Leave a Comment