Skip to content

Instantly share code, notes, and snippets.

@ctanis
Created April 3, 2013 13:11
Show Gist options
  • Save ctanis/5301075 to your computer and use it in GitHub Desktop.
Save ctanis/5301075 to your computer and use it in GitHub Desktop.
open man pages in Preview.app (caches generated pdfs in ~/.manpath)
#!/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
@ctanis
Copy link
Author

ctanis commented Apr 3, 2013

i should say that it "opens" the man page in whatever is configured to open pdf files...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment