Re: [notmuch] viewing text/html (inline or otherwise)

Subject: Re: [notmuch] viewing text/html (inline or otherwise)

Date: Tue, 09 Feb 2010 22:10:02 -0800

To: Carl Worth, Alex Ghitza, notmuch@notmuchmail.org

Cc:

From: Keith Packard


On Tue, 09 Feb 2010 16:22:56 -0800, Carl Worth <cworth@cworth.org> wrote:

> I know that Keith is using a little script he wrote so that he can hit
> '|' on a message and pipe it to his script. The script then uses a
> utility, (munpack?) to extract all the various MIME parts to a temporary
> directory and then run a web broswer on that directory. Perhaps Keith
> would be so kind as to share that script with the community here.

It's not much of a script, I call it 'view-html'

#!/bin/sh
dir=`mktemp -d`
trap "rm -r $dir" 0
cat "$@" > "$dir"/msg
if munpack -C "$dir" -t < "$dir"/msg 2>&1 | grep 'Did not find'; then
    sed -n '/[Hh][Tt][Mm][Ll]/,$p' "$dir"/msg > $dir/part1.html
    rm "$dir"/msg
fi
for i in "$dir"/part*; do
    if grep -q -i -e '<html>' -e 'text/html' "$i"; then
	iceweasel "$i" &
	sleep 3
	exit 0
    fi
done

Note that if iceweasel isn't already running, it seems to shut down when
the script exits. I don't know why.

-- 
keith.packard@intel.com
part-000.sig (application/pgp-signature)

Thread: