There seems to be a way to get man pages to display in color (see here. It involves setting environment variables associated with less and adding these definitions to .bashrc
. I tried doing the same in config.fish
for the fish shell, but got no color output.
How to get color man pages in the fish shell?
If you want these colors to be added only when viewing man pages, not for everything you view in
less
, you should set these variables in a wrapper function forman
instead of putting them in yourconfig.fish
.The whole process is to create a new file at
~/.config/fish/functions/man.fish
, and inside it define a functionman
that sets the necessary environment variables, then calls the originalman
usingcommand
, passing in arguments using$argv
.This is my version of the wrapper function:
~/.config/fish/functions/man.fish
You can set the configuration by the following commands,
Assuming you use less as your pager, put this in
~/.config/fish/config.fish
:If you see
\e[0m
etc appearing when you view the man page, try adding this line as well:It's possible to use
set_color
instead of direct ANSI sequences. In fact, this allows you to use any color you want, by using 24-bit color hexadecimal escapes, like(set_color FF55AA)
.I suggest a very nice tool called batcat provided by https://github.com/sharkdp/bat.
bat
package is available on Ubuntu since 20.04 ("Focal") and Debian since August 2021 (Debian 11 - "Bullseye")and its command isbatcat
which is a cat replacement with wings.From the git docu:
Install this bat package
I love the Monokai theme and therefore I added this command into my
.zshrc
:In case you are using
fish
shell add this line to your~/.config/fish/config.fish
file:A list of installed color-themes can be printed by following command
Here a screenshot of
man 3 printf