Easier to read man pages

The man utility is an ancient and good way of documenting command line tools in Unix.  The downside is that it will display it in some sort of Unix pager, and I can never figure out how to go back up a page.  This can be a pain when you are going through a ton of switch descriptions, and you pass the one you want to read.  The only alternative is to exit, reload, and then try to stop on the right page.  This script (below the fold) I put together will keep a copy in PDF form and open it in preview.  The caching feature is nice because the conversion can be a bit slow at times (Note you’ll have to set your own location for the cached man pages) Update: hitting ‘u’ does a page up when reading man pages in terminal, but I still find the indexed searching and extra formatting nice in Preview.

# !/bin/bash
if [ "$1" ]; then
    f=~/UNIX/manpdf/$1.pdf
    if [ -e $f ]; then
        open $f
    else
        mantest=man -w $1
        #echo $mantest
if [ ! -z $mantest ];then
            echo Converting...
            man -t $1 | pstopdf -i -o $f
            open $f
        else
            echo No man page available for $1
        fi
    fi
fi

2 comments ↓

#1 Shrop on 10.29.08 at 4:36 pm

Great idea!

shrop

#2 Elio Grieco on 11.13.08 at 12:00 am

Cool shell script. Reminds me of Bwana ( http://www.bruji.com/bwana/ ) without adding the url handling.

Leave a Comment