#!/bin/sh -
grep="${GREP-grep}"
# Note: with Firefox 3 you need to set browser.bookmarks.autoExportHTML true
# in about:config to get bookmarks.html
bookmark="${BOOKMARK-$HOME/.mozilla/bookmarks.html}"
htmlview="${HTMLVIEW-webrowse -s}"
beghtml='
'
endhtml='
'
# grepbm - convenience kludge to grep through browser bookmarks
# Steve Kinzler, kinzler@cs.indiana.edu, Aug 98
# http://www.cs.indiana.edu/~kinzler/home.html#web
title=`echo "$0 $*" | sed 's/&/&/g; s/</g; s/>/>/g'`
view=; bad=
case "$1" in
-b) view=t; shift;;
-h) bad=t; shift;;
esac
case "$bad" in
?*) cat << EOF 1>&2
usage: $0 [ -b ] [ $grep options ] regexp
-b view the output in a web browser ($htmlview)
EOF
exit 1;;
esac
case "$view" in
'') exec $grep "$@" "$bookmark";;
esac
(cat <
$title
$beghtml
EOF
$grep "$@" "$bookmark"
cat <
EOF