O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Linux Desktop Hacks
By Nicholas Petreley, Jono Bacon
March 2005
More Info

HACK
#54
View Word and PDF Files from Within Mutt

[Discuss (0) | Link to this hack]

It is certainly possible to launch a GUI application such as OpenOffice.org or Acrobat Reader to view Word and PDF email attachments in Mutt. But Mutt users aren't always using a graphical desktop, so it's handy to be able to view these documents as text, right inside the message itself.

Here's how to do it. First, you need to edit the Mutt configuration file. The default configuration file is usually /etc/Muttrc, but you'll most likely want to create your own even if you do it by copying the default and modifying it. Mutt lets you define your user configuration file as either ~/.muttrc or ~/.mutt/muttrc. Modify your personal Mutt configuration file to point to a custom mailcap file. For example:

set mailcap_path="~/mailcap.mutt"

Then edit the ~/mailcap.mutt file to include these two lines:

application/pdf; pdftohtml -q -stdout %s | w3m -T text/html; copiousoutput

application/msword; wvWare -x /usr/lib/wv/wvHtml.xml %s 2>/dev/null | w3m -T text/html; 
copiousoutput

Now all attached PDF and Microsoft Word documents will appear within the text of the email. Granted, the formatting isn't as pretty as when you view Word or PDF documents [Hack #52] and [Hack #53], because all the output is piped into Mutt's own display, and not in a specialized pager, such as elinks or w3m. But you can still read the content of the attached file. And if it interests you enough to read it in a better format, you can save the file and read it with whatever program you want—including one of the scripts in the previously mentioned hacks.


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.