Scrawls from Preston...

Powered by Pelican.

Tue 28 October 2008

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/bashif [ "$1" ]; then    f=~/UNIX/manpdf/$1.pdf    if [ -e $f ]; then        open $f    else        mantest=`man -w $1`        #echo $mantestif [ ! -z $mantest ];then            echo Converting...            man -t $1 | pstopdf -i -o $f            open $f        else            echo No man page available for $1        fi    fifi


https://ptone.com/dablog