Quoth Chris Brennan on Tuesday, 14 June 2011:
> * stardiviner <numbch...@gmail.com> [2011-06-15 00:49:04 +0800]:
> 
> > How to set mailcap fot mutt ? I googled it. nothing similar found. 
> > I want to let mailcap can use some command like gunzip to get a list of 
> > archive. 
> > Just like a feature in Ranger file manager. 
> > If you know mailcap, can you give me an example. Then I will know how to 
> > write them .
> > Thanks in advance.
> 
> Here is the two lines I use in my ~/.mailcap
> 
> ch...@stewie.xaerolimit.net:~$ cat .mailcap
> text/html; /usr/bin/links2 -dump -force-html %s
> application/pgp-keys; pgp -f < %s ; copiousoutput
> ch...@stewie.xaerolimit.net:~$
> 
> Keep in mind, that I use mutt strictly on a headless box and I shell in 
> to it to read my mail. So I don't have any mailcap settings for example 
> to pass pdf's to a viewer (since this box doesn't run X, that wouldn't 
> do me any good, although I could do something like pdf2text but that 
> never looked right for me.
> 
> In your case though, if the file really is gzip, you could do
> 
> "application/gzip; gzcat -" ... provided the gzipped file is a textfile, 
> else you could gzip -d and pipe it to your reader of choice, if it's 
> been tar'd, then tar -xf - | your_reader might be more appropriate.
> 
> P.S. I'm still someone new to mailcap, so I might be wrong, there may be 
> a better way to do this already. ither way, what ever you do find, post 
> it to the list so it can be archived and found later.
> 
> -- 
> > A: Yes.
> > >Q: Are you sure?
> > >>A: Because it reverses the logical flow of conversation.
> > >>>Q: Why is top posting frowned upon?
> > http://xkcd.com/84/ | http://xkcd.com/149/
> > GPG: D5B20C0C (6741 8EE4 6C7D 11FB 8DA8  9E4A EECD 9A84 D5B2 0C0C)
> ------------------------------------------------------------------------

For contrast, here's my .mailcap, which works for X and non-X modes:

text/html;                      /home/sterling/bin/browser %s;
text/calendar;                  icalmutt.rb -i 
'mailto:sterl...@camdensoftware.com' %s;
image/*;                        mutt_bgrun qiv %s; edit=mutt_bgrun gimp %s; 
test=RunningX;
application/pdf;                mutt_bgrun mupdf %s; test=RunningX;
application/ms-tnef;            tnef -t %s; copiousoutput; needsterminal;
application/msword;             mutt_bgrun libreoffice %s; test=RunningX;
application/vnd.openxmlformats-officedocument.wordprocessingml.document; 
mutt_bgrun libreoffice %s; test=RunningX;
application/msword;             antiword %s; copiousoutput; needsterminal;
application/vnd.openxmlformats-officedocument.wordprocessingml.document; 
antiword %a | less;
application/x-zip-compressed;   unzip -l %s; copiousoutput; needsterminal;
application/zip;                unzip -l %s; copiousoutput; needsterminal;
audio/mpeg;                     mplayer %s;

Here's the "browser" script referenced above:

#!/bin/sh
if RunningX
then
   firefox $* >/dev/null 2>&1 &
   sleep 3
else
   w3m -t text/html $*
fi

The "sleep" is to keep mutt from deleting the temp file before Firefox
can load it.

"RunningX" is a little C program I downloaded from the web somewhere:

#include <stdlib.h>
#include <X11/Xlib.h>
int main(int argc, char *argv[])
{
  exit(XOpenDisplay(getenv("DISPLAY")) == NULL);
}

Build it with this Makefile (on FreeBSD -- it will need some minor
adjustments for other platforms):

RunningX: RunningX.c
        gcc -Wall -I/usr/local/include -o RunningX RunningX.c 
/usr/local/lib/libX11.so /usr/local/lib/libX11-xcb.so
        strip RunningX

icalmutt.rb can be downloaded as part of this:
http://www.chipstips.com/?p=538

The other apps referenced are available from various locations online or
the FreeBSD ports system.  Substitutions allowed ;)

-- 
.O. | Sterling (Chip) Camden      | http://camdensoftware.com
..O | sterl...@camdensoftware.com | http://chipsquips.com
OOO | 2048R/D6DBAF91              | http://chipstips.com

Attachment: pgpsUUSy8WeWT.pgp
Description: PGP signature

Reply via email to