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 ↓
Great idea!
shrop
Cool shell script. Reminds me of Bwana ( http://www.bruji.com/bwana/ ) without adding the url handling.
Leave a Comment