Viewing attachments using the Mac apps doesn't work out of the box. You can easily set up the image-viewer pine pref to use xv, but not Preview. And Word / PowerPoint / Excel attachments must be saved to disk first. The following two files will let you view attachments straight from pine. First, the problem: This is two-fold. One is that if you use the open command, it is spawned and returns immediately. Once it returns, pine deletes the temporary file it made of the attachment, so Excel (or whatever app open launched) can't find the file. The second is that the Preview app doesn't use the magic (man magic) information about a file (man file; it's a useful command). Preview uses file extensions, and pine doesn't give valid mime-type extensions to its temporary files.
Read the rest of the hint for the solution...
OK, this goes in your .mailcap file in your home directory (the first four lines below should be two lines; remove the line break and replace it with a space character):
Side effects: the /var/tmp/ directory where Pine writes its tmp files to fills up, as does the ~/tmp/pine_attach/ directory. Not a big deal, as you can add a line to the script to clean them up.
Read the rest of the hint for the solution...
OK, this goes in your .mailcap file in your home directory (the first four lines below should be two lines; remove the line break and replace it with a space character):
Application/VND.MS-Excel; exec open -a
'/Applications/Microsoft Office X/Microsoft Excel' %s<br>
Application/MSWORD; exec open -a
'/Applications/Microsoft Office X/Microsoft Word' %s<br>
Application/OCTET-STREAM; exec open %s<br>
Application/PDF; /Users/mankoff/bin/pine_attach %s<br>
Image/JPEG; /Users/mankoff/bin/pine_attach %s<br>
Image/PNG; /Users/mankoff/bin/pine_attach %s<br>
Image/GIF; /Users/mankoff/bin/pine_attach %s<br>
The first two lines use Excel and Word semi-directly to open the tmp file. They don't need valid extensions, so they can be used on the tmp file name. The information about "VND.MS-EXCEL" is found by going to the attachment in pine and pressing "A". Adding powerpoint files is left as an excercise to the reader. But Preview can't be launched via exec-open-Preview because it needs file extensions. So the pine_attach shell script is used. It is simply this:
#!/bin/bash<br>
file=`echo $1 | cut -d"/" -f4`<br>
type=`file -bi $1 | cut -d"/" -f2`<br>
cp $1 /Users/mankoff/tmp/pine.attach/$file.$type<br>
open /Users/mankoff/tmp/pine.attach/$file.$type<br>
This gets the tmp file name, the tmp file type (i.e. what extension it should have), and copies it a tmp directory, then calls open on it. This script would probably work on the Word and Excel files mentioned above, but I figured if I could handle them in a more direct manner I would.
Side effects: the /var/tmp/ directory where Pine writes its tmp files to fills up, as does the ~/tmp/pine_attach/ directory. Not a big deal, as you can add a line to the script to clean them up.
•
[7,503 views]

