Created
April 3, 2013 13:11
-
-
Save ctanis/5301075 to your computer and use it in GitHub Desktop.
open man pages in Preview.app (caches generated pdfs in ~/.manpath)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Based on this Mac OS X Hint: | |
#http://hints.macworld.com/article.php?story=20110511111211385 | |
#Modified for input of multiple commands to seperate .PS files | |
CACHE=~/.mancache | |
mkdir -p $CACHE | |
COMMANDS="$@" | |
for f in $COMMANDS | |
do | |
if [ -e $CACHE/$f.pdf ]; then | |
echo found existing man page in cache: $CACHE/$f.pdf | |
open $CACHE/$f.pdf | |
else | |
echo generating man page for $f | |
ps=`mktemp -t $f`.ps | |
man -t $f > "$ps" | |
if [ $? != 0 ]; then | |
echo man page for $f not found | /usr/local/bin/growlnotify | |
else | |
/usr/local/bin/ps2pdf $ps $CACHE/$f.pdf | |
open $CACHE/$f.pdf | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i should say that it "opens" the man page in whatever is configured to open pdf files...