A script to open man pages in BBEdit

Jan 04, '06 06:22:00AM

Contributed by: jmdevaney

I use BBEdit to read man pages with the following script -- I'm sure you could use Text Wrangler or any other text editor, with some modifications. The script checks a predefined storage area for an existing plain text version of the man page, and opens it if one exists.

If no plain text version is found, then the script creates the file, changes its creator type (assuming the Developer Tools are installed) to R*ch (BBEdit) and opens the file using BBedit's command line tools.

#!/bin/bash

if [ -f /usr/bin/bbedit ] ; then

  MANTEXT=/Users/username/man

  if [ -f $MANTEXT/$1.txt ] ; then
    bbedit $MANTEXT/$1.txt
  else
    man $1 | col -b > $MANTEXT/$1.txt
    if [ -f /Developer/Tools/SetFile ] ; then
      /Developer/Tools/SetFile -c R*ch $MANTEXT/$1.txt
    fi
    bbedit $MANTEXT/$1.txt
  fi
else
  echo "BBEdit is not installed!"
fi
[robg adds: This worked for me as described; just make sure you change the MANTEXT line to point to the directory you'll use to hold the text versions of the pages.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=200512300851586