Man Pages

I use the command line a lot and I love the “man” pages (manual pages) built into Unix. But I really don’t like how they interrupt the flow of my work on the command line. I wanted some way to see nicely formatted man pages in a separate window. There is some software available to do this, but it feels cumbersome to me. I just wanted the “man” command to bring up a beautiful window. This hint pointed me in the right direction. It popped up a nice Preview window with a PDF version of the man page. Applying a few ideas from the comments on the hint and a few ideas of my own (checking for success) left me with a good substitute for “man”.

Setup

I created a file ~/bin/preman which contained the script to convert a man page to PDF and display it…

#!/bin/sh
man -t $1 > /tmp/$1.ps
if [ -s /tmp/$1.ps ]; then
	pstopdf /tmp/$1.ps /tmp/$1.pdf
	rm /tmp/$1.ps
	open /tmp/$1.pdf
fi

Then I added the following line to my ~/.bash_profile

alias man='~/bin/preman'

Known issues

One problem with this approach is that I can’t easily hunt for content using man. Instead I have to use /usr/bin/man to do things like /usr/bin/man -a ls. I decided that I wanted the default man to be pretty in a separate window more than I wanted these other man cases handled smoothly. Of course, I could have both if I wrote a fancier script, but that’s not something I’m spending my time doing.