Admittedly, this is perhaps more of an interesting trick rather then a needed feature; However, if you’ve ever wanted to print man pages or simply read them in a nice, anti-aliased document view instead of within the Terminal, here’s a tip you might like. The following bash script (and credit goes 100% to my friend Victor, who is sans-blog) will format and open man pages in Preview:
#!/bin/bash
cmd=$1
if [ -z $cmd ]; then
me=`basename $0`;
echo "Usage: $me command_name";
exit;
fi
man $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "No man page for $cmd";
exit;
fi
man -t $cmd|open -f -a /Applications/Preview.app
On my box, I called the script ‘manpreview’ and dropped it in ~/bin/ for easy access. Once you `chmod u+x` it (and have ~/bin/ in your path), you’ll be able to do fun things like `manpreview tcpdump` for some extended reading.
August 30th, 2006 at 2:21 pm
Thanks.
May 22nd, 2007 at 8:07 am
This is GREAT! Thanks for the tip. I’m tagging this on Del.icio.us immediately!