optionally viewing attachments
Guys,
First, many thanks to Gunnar for this great tool! I've been using mail for
a very long time, and like it, but handling attachments and so on was a real
pain. A sysadmin pointed me at nail, and it is a beautiful thing :)
I'm trying to get some stuff set up, and I have some newbie questions I've
yet to figure out. First, I like the idea of only opening attachments when
I ask for it. Gunnar had this to say last year:
> Another possibility is to have a second set of pipe-x/y-style variables
> that would not be effective with the regular "print" and "next" commands,
> but with a special "print-a-trusted-message" one.
I don't suppose this was ever added, I guess? That would be ideal for me:
doing next gets me normal message without doing anything external to
attachments, but I can invoke a special-print anytime I want to fire up
external programs on the attachments . . .
In the meantime, I'm doing something rather crude, and I post it here in
case it helps someone, or perhaps someone can suggest a more elegent or
flexible way to do something like it. What I've got now is I don't fire
up any external viewers by default, and when I need to, I do a "call wa"
(write attachment). This is defined in my .nailrc as:
====================
define wa {
! rm -f /home/whaley/.nailatt/*
cd /home/whaley/.nailatt
w /dev/null
! /home/whaley/local/bin/da.sh
cd
}
====================
da.sh is a shell script, defined as follows:
====================
#!/bin/sh
for file in /home/whaley/.nailatt/*
do
new=`echo "${file}" | sed -e "s/\.pdf//"`
# echo $new, $file
if [ -e "${new}.pdf" ]
then
xpdf ${new}.pdf
fi
new=`echo "${file}" | sed -e "s/\.ps//"`
if [ -e ${new}.ps ]
then
gv ${new}.ps
fi
new=`echo "${file}" | sed -e "s/\.gif//"`
if [ -e ${new}.gif ]
then
display ${new}.gif
fi
new=`echo "${file}" | sed -e "s/\.png//"`
if [ -e ${new}.png ]
then
display ${new}.png
fi
new=`echo "${file}" | sed -e "s/\.jpg//"`
if [ -e ${new}.jpg ]
then
display ${new}.jpg
fi
====================
Here are some improvements I'd like if someone knows how to do them:
(1) Is there a way to pass an argument to a definition, so that
I could give a message number to write? If so, can we also
say "use the current" message if that arg is not defined?"
(2) Is there some way to tell write to only ask me for the name of
unnamed attachments?
(3) Is there a way to pipe the attachment names directly to my
script, so I don't have to do the "file in *" trick?
(4) Can you pass a directory somehow to write, to avoid the cd
back and forth that I do?
(5) Could make the script fancy, so it creates a unique subdir for
viewing, and is started in background, so that it doesn't block,
then you would not have to quit each attachment to see the next,
and indeed could displaying multiple message's attachment at
once (would require waiting until xpdf completes before deleting
the file, obviously).
(6) More elegant way to accomplish same functionality.
Any tips appreciated,
Clint