How to change your manpaging utility in Linux/Unix


When opening manpages with man on a Linux/Unix system, the manpage is printed and fed into a line viewer such as less (1). However, the utility used to open and view manpages can be easily changed by exporting the $MANPAGER environment variable to something else. Other possible utilities include batcat, vim, and even gedit or Firefox just for fun.

(NOTE: do not use gedit or Firefox as your primary manpager unless you are a psychopath.)

Setting the $MANPAGER variable

The $MANPAGER variable should contain some sort of shell sequence which retrieves input from stdin and does something with it. Knowing this, we can set our manpaging utility to different text/line viewing programs.

# to use any of these, copy it into your shell's init file (.bashrc, .zshrc, etc.)

# set manpager to batcat
export MANPAGER="sh -c 'col -bx | batcat -l man -p'"

# set manpager to vim
# note: this one was taken from Distrotube's .zshrc. Link
export MANPAGER='/bin/bash -c "vim -MRn -c \"set buftype=nofile showtabline=0 ft=man ts=8 nomod nolist norelativenumber nonu noma\" -c \"normal L\" -c \"nmap q :qa<CR>\"</dev/tty <(col -b)"'

# set manpager to gedit
export MANPAGER="sh -c 'col -bx | cat > /tmp/man; gedit -s /tmp/man; rm /tmp/man'"

# set manpager to firefox
export MANPAGER="sh -c 'col -bx | cat > /tmp/man; firefox -new-tab /tmp/man; rm /tmp/man'"

# print manpages to stdout by default
export MANPAGER="cat"

# speak manpages with espeak
export MANPAGER="sh -c 'col -bx | espeak'"

# print manpages in rainbow
export MANPAGER="sh -c 'col -bx | lolcat'"

Homepage Posts