Bat: How to Set Bat as the Man Pager

Updated

Learn how to set bat as the man pager for colorful man pages

Bat: How to Set Bat as the Man Pager

Before we start, make sure you have bat installed on your computer. If you don't have it yet, run this command:

brew install bat

By default, man shows pages in a pager called less, and everything is one colour. To make bat the pager, add this line to your shell config. I'm using zsh, so that's ~/.zshrc:

echo 'export MANPAGER="bat -plman"' >> ~/.zshrc

If you use bash, add the same line to ~/.bashrc instead. The -p flag turns off the borders and line numbers, and -l man tells bat the text is a man page, which gives you the syntax colours.

Now reload your config:

source ~/.zshrc

To make sure it worked, open any man page, for example man ls. The headings, command names and options are now highlighted, and you still press q to quit.

undefined

If you ever want to go back, just delete that line from your config file and open a new terminal.