#!/bin/bash # bbman -- converts man pages to plain text and opens them in your favorite text editor ARGS=1 ERR_NOARGS=66 if [ $# != $ARGS ] ; then echo echo "Usage: `basename $0` < man-page >" echo exit $ERR_NOARGS fi MANTEXT="/Users/Shared/Documents/man" ## If we haven't done this before, convert the man page to text if [ ! -f "${MANTEXT}/${1}.txt" ] ; then man $1 | col -b > "${MANTEXT}/${1}.txt" ## If SetFile is installed, set the file's creator to R*ch (BBEdit) [ -f /Developer/Tools/SetFile ] && /Developer/Tools/SetFile -c R*ch "${MANTEXT}/${1}.txt" fi ## Open in BBEdit or TextWrangler or TextEdit bbedit "${MANTEXT}/${1}.txt" 2>/dev/null || edit "${MANTEXT}/${1}.txt" 2>/dev/null || open -e "${MANTEXT}/${1}.txt" exit 0