Thursday, May 17, 2012

More mutt goodness

I have been using mutt for some time now as my primary email client, and have found that I have not missed using any of the more graphical interfaces like Mac Mail, or Gmail web interface. Not even to look at HTML emails, PDF documents, or Word documents. Thanks to a couple of open source utilities, I can convert these documents to text, and read them from within mutt, leading to a seamless experience, and a much more pleasant email workflow.

The following lines in your  ~/.mailcap config file configure the utilities and do the magic:

HTML emails

text/html; links -html-assume-codepage utf8 -html-numbered-links 1 -dump %s; copiousoutput

I use the links browser to do the conversion from HTML to text. There are many other options to use, such as Lynx, or w3m, but I like links because it formats the HTML tables better than Lynx or w3m, and handles utf8 characters better. You can also turn off the html numbered links easily if you choose to.

PDF files

application/pdf; pdftotext -layout /dev/stdin -; copiousoutput

I receive a lot of resumes, and hate to open them in Preview or Adobe Acrobat. For me, nothing beats looking at resumes in text mode where I can focus on the candidates' skills, and experience, without being distracted by formatting and colors.

For the conversion I use the pdftotext script which you can get by installing the poppler macport.

Word documents

application/msword;             antiword -f -s %s  2> /dev/null; copiousoutput
application/vnd.openxmlformats-officedocument.wordprocessingml.document; %s - 2> /dev/null; copiousoutput

There are two formats for word documents, the older DOC format, and the newer DOCX format. For the older format I use antiword, which you can install through macports, and for the newer format I use the perl script docx2txt, which you can download from the docx2txt sourceforge repository.

I have not had a need to convert powerpoint slides or excel spreadsheets to text so far, but if you know of any utilities that help, let me know.

No comments :

Post a Comment