Skip to content

Instantly share code, notes, and snippets.

@takuya
Created July 7, 2014 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/5b0e2c0bb26ce79338cc to your computer and use it in GitHub Desktop.
Save takuya/5b0e2c0bb26ce79338cc to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if ! $( type -P groff >/dev/null); then
echo groff is not found.
echo please install groff
exit 1;
fi
name=$1
name=$( echo $name | tr "[:upper:]" "[:lower:]")
path=$( man -W $name );
if test "$path" != "" && [ -f $path ] ; then
$(groff -Tps -mandoc -c $path 2>/dev/null| ps2pdf - 2>/dev/null 1>./$name.pdf )
echo printed to ./$name.pdf;
if [[ `uname -a` = Darwin* ]]; then
open ./$name.pdf
fi
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment