Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Very much improved' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Very much improved
Authored by: owain_vaughan on May 15, '01 06:37:29AM
#!/bin/sh

if [ $# -eq 2 ]; then
  m=`man -w $1 $2` || exit
  PAGE=`basename $m`
  PDF=/tmp/$PAGE.pdf
  if [ ! -e $PDF ]; then
    c=`grog $m`
    $c | ps2pdf - $PDF
  fi
  open $PDF 
else
  m=`man -w $1` || exit
  for x in $m; do
    PAGE=`basename $x`
    PDF=/tmp/$PAGE.pdf
    if [ ! -e $PDF ]; then
      c=`grog $x`
      $c | ps2pdf - $PDF
    fi
    open $PDF
  done
fi

Using this version you can use the standard BSD 'man' semantics for looking up man pages - ie.
% superman ls % superman open % superman 2 open

Where there are multiple matches - all matching pages are opened as PDF files. Again checks are made to stop duplicating already created pages, and to exit cleanly if there are no matches.

[ Reply to This | # ]
Very much improved & smaller
Authored by: owain_vaughan on May 18, '01 05:44:45AM
Just in case everybody isn't bored by this already - this is the version I now use. It's pretty much identical to the previous one, but redundant variables are removed and therefore the new one-line 'if' blocks can be compressed onto one line....
#!/bin/sh
if [ $# -eq 2 ]; then
m=`man -w $1 $2` || exit
PDF=/tmp/`basename $m`.pdf
[ ! -e $PDF ] && `grog $m` | ps2pdf - $PDF
open $PDF
else
m=`man -w $1` || exit
for x in $m; do
PDF=/tmp/`basename $x`.pdf
[ ! -e $PDF ] && `grog $x` | ps2pdf - $PDF
open $PDF
done
fi
Simple eh? :)

[ Reply to This | # ]