Enjoying alpine to the fullest

Submitted by dag on Tue, 2008/03/18 - 18:08

I know most of you don't care about my alpine fetish, but this goes out to my fellow alpine users :-)

Pine was almost dead for years and likely because of that I never reconsidered optimising my mail-usage. With alpine's rebirth I have been busy improving my daily overload of personal messages.

One of the things I was loosing considerable time with was attachments. I often get non-text attachements (like RPMs, Word documents, PDF, archives) and to remotely look at them was a major pain (save attachement, remember name, copy to local machine or somewhere shared, then open to find out it was useless). Especially when you just need a small piece of information, the drag of going through this often caused me to "bounce" my mail to Google Mail and use the browser. And even for patches, it could be better.

So yesterday I revisited my ~/.mailcap file and improved it to only use terminal applications and now it includes the following entries:

### antiword
application/msword; antiword -t %s; copiousoutput

### cat
application/pgp-signature; cat %s; copiousoutput

### cdiff (needs coloroutput)
text/x-diff; cdiff %s; needsterminal
text/x-patch; cdiff %s; needsterminal

### elinks (needs input)
application/xhtml+xml; /usr/bin/elinks -force-html %s; needsterminal
text/html; /usr/bin/elinks -force-html %s; needsterminal

### mc (needs input)
application/x-7zip; /usr/bin/mc %s#u7z; needsterminal
application/x-bzip2; /usr/bin/mc %s#utar; needsterminal
application/x-gzip; /usr/bin/mc %s#utar; needsterminal
application/x-patch; /usr/bin/mc %s#patchfs; needsterminal
application/x-rpm; /usr/bin/mc %s#rpm/CONTENTS.cpio#ucpio; needsterminal
application/x-tar; /usr/bin/mc %s#utar; needsterminal
application/zip; /usr/bin/mc %s#zip; needsterminal

I can now just go inside archives and RPMs (using midnight commander), I can look inside Word documents, HTML messages can be browsed and patches are colorized ! Only PDF files needs some more love and attention. To summarize, I rule :-)

(Leave your Thunderbird and Evolution remarks to yourself please. No swearing either !)

BTW Alpine 1.10 is released !

Useful stuff

I'm a mutt user, but the mailcap rules work just the same. I'm already using antiword but I'm still having trouble with PDF files. I'd be quite interested to see your solution.

By the way: The following might be useful too. It's only usable for very, very simple excel documents, but it's better than nothing: application/vnd.ms-excel ; /usr/bin/xls2csv %s ; copiousoutput

xls2csv: command not found

Cannot find what project provides this xls2csv convertor. Do you have a project-name or package-name ?

My PDF handling for mailcap is below, the problem is that the error-output is not silenced by the -q option as the help indicates. The PS output is ok, but not amazing.

The benefit of converting to HTML and then sending it to elinks, is that layout is much better and you can follow links.

### pdf (needs input)
application/pdf; pdftohtml -q -p -hidden -nodrm -stdout %s | elinks -force-html; needsterminal
application/postscript; ps2ascii %s; needsterminal

Let me know if you can improve it :-)

Wrap it in a shell script

The obvious approach would be to wrap the command in a shell script, and then redirect pdftohtml's stderr to /dev/null.

#! /bin/sh
# my-pdftohtml
pdftohtml -q -p -hidden -nodrm -stdout "$@" 2>/dev/null

That would be the expected behaviour...

...if only it would be sending this output to stderr (which it does not).

[dag@horsea ~]$ pdftohtml -q -p -hidden -nodrm -stdout centos-nl.pdf 2>/dev/null | grep 'Error :' | uniq -c
777 Error : Bad color