On Sun, Nov 28, 2010 at 08:42:05PM +0100, Jose M Vidal wrote:
> Hi,
> While opening and viewing mutt attachments, mutt is not available
> until I close the attachment app (evince, chrome, etc)
> Is there any way to open attachments while keeping the mutt terminal 
> available?
> Thanks a lot!

Here's the ksh script I use (on Solaris) with mutt to view PDF
attachments.  It could also be modified to deal with other attachment
types.

#!/usr/bin/ksh -p

# for viewing PDFs in attachments when run via .mailcap and mutt

# Note, that the gnome pdf viewer is often runs as a background  process
# and the mailcap processing is deleting the temp attachment file so to
# workaround this I'm making a copy of the mailcap temp file then
# running the pdfviewer with that file.

tmpdir=/tmp/waf_attachments

# copy the attached file fed in by mutt via the .mailcap
if [[ ! -f $1 ]]
then
        print -u2 "Error: no attachment file provided, aborting."
        exit 1
fi

if [[ ! -d $tmpdir ]]
then
        mkdir $tmpdir || exit 1
fi

cp -f "$1" $tmpdir || exit 1
# just get the file name from the $1 path
file="${1##*/}"
#print "$file copied to $tmpdir"
exec ~/bin/pdfview "$tmpdir/$file"
# End of script

In my ~/.mailcap I have:
application/octet-stream; $HOME/bin/view_pdf_attachment %s; test=test %{name} = 
*.pdf;
application/pdf; $HOME/bin/view_pdf_attachment %s

Note that this method leaves files in the /tmp/waf_attachments dir which
may need to be periodically cleaned up (I use a cronjob for that) but
sometimes it's nice to be able to access the file in that temp dir.  And
there is no timing/race condition issue to deal with using this method.

-- 
Will Fiveash

Reply via email to