MacOS – way to color parts of the man pages on the terminal

colormacosterminal

I would like to color some parts of the output of the command man, specifically I would like to be able to change the color of the most important things, for example the options or the first introduction to each command.

Is it possible?

I know I can change the color of the prompt and of the output of the command grep and ls, so I thought we could actually customise more things (if yes, in general, could you please show me a complete guide?).

Best Answer

Assuming you're fairly default and using bash:

Short version:
Add the following to your .bashrc file:

export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode – red
export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode – bold, magenta
export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode
export LESS_TERMCAP_so=$(printf '\e[01;33m') # enter standout mode – yellow
export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode
export LESS_TERMCAP_us=$(printf '\e[04;36m') # enter underline mode – cyan

If you use ZSH as part of oh-my-zsh there's a plugin for man-page coloring: colored-man