Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently managed to set up the my mailcap so that mutt can show html e-mails in the message window:

# ~/.mailcap
text/html; lynx -dump '%s' | more; nametemplate=%s.html; copiousoutput;

which is automated by:

# ~/.muttrc
auto_view text/html

Although I think lynx does a decent job on decripting the html to text, sometimes this doesn't cut it and I would like to be able to open the html attachment in my web-browser (luakit).

Is there a way to transparantly do this? A good workflow for me would look like:

  1. open mail (lynx converts it)
  2. see that it is to complilcated for lynx
  3. press "v"
  4. navigate to html attachment
  5. press "enter" to open in luakit.
share|improve this question
    
This doesn't work for you ? text/html; luakit %s besides, auto_view doens't matter in this case, since html are actually attachments –  warl0ck Jul 10 '12 at 9:45

1 Answer 1

up vote 8 down vote accepted

You can do this with mutt's mime support.

In addition, you can use this with Autoview to denote two commands for viewing an attachment, one to be viewed automatically, the other to be viewed interactively from the attachment menu.

Essentially, you include two options in your mailcap file1.

text/html; luakit '%s' &; test=test -n "$DISPLAY"; needsterminal;
text/html; lynx -dump %s; nametemplate=%s.html; copiousoutput;

The first entry tests that Xis running, and if it is, it hands the file to luakit. The default, however, is determined by the copiousoutput tag, so it will be rendered in mutt by lynx.

You will need these options in your .muttrc:

auto_view text/html                                   # view html automatically
alternative_order text/plain text/enriched text/html  # save html for last

If you want to look at it in your browser, it is just a matter of hitting v to view the attached HTML and then m to send it to mailcap.

For convenience, I bind Enter to that function in muttrc:

bind attach <return>    view-mailcap


1. Note, I don't use lynx or luakit, so these options are indicative only.
Shamelessly reproduced from this blog post...

share|improve this answer
    
If you want to avoid the needsterminal for luakit have a look a Gary Johnsons mutt-netscape script. –  Thor Jul 12 '12 at 22:49
1  
Does it really have to read text/html; text/html; luakit ... with the text/html repeated? –  Jens Apr 7 '13 at 15:54
    
@Jens It was a typo: removed, thanks. –  jasonwryan Jul 20 at 17:17
    
Is there a way to do this while disabling the loading of external resources (for privacy reasons)? –  a3nm Aug 5 at 20:35
    
@a3nm That all depends on the settings in the browser you hand off to... –  jasonwryan Aug 5 at 20:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.