#!/bin/sh # Author: John Eikenberry # License: CC0 # Unpacks all attached files and kicks off an image view on the directory (in # this case gqview which I like). Cleans up the images/directory afterwards. # # To use from mutt include this keybinding (replace with your preference) # in the approparite config file. # ## view a bunch of attached images #macro index "/tmp/tmpbox\nmutt-view-images\n" "View images" #macro pager "/tmp/tmpbox\nmutt-view-images\n" "View images" tmpdir=/tmp/muttimagetmpdir mbox=/tmp/tmpbox trap 'cleanup_on_error' 0 cleanup_on_error () { if [ "$?" -ne 0 ]; then rm -f $files $mbox rmdir $tmpdir fi } mkdir $tmpdir cd $tmpdir files=`munpack -q -t -C $tmpdir $mbox | sed 's/([^()]\+)//g'` (trap 'cleanup' 0 cleanup () { rm -f $files $mbox rmdir $tmpdir } gpicview) > /dev/null 2>&1 & ## vim: ft=sh