On Mon, Jan 10, 2011 at 10:59:01PM +0100, Jose M Vidal wrote:
> None of the possibilities is actually working.
> But at least I have clues enough to go deeper with .mailcap options,
> which I clearly ned to learn,
> Thanks again.
>
> >
> > actually, forget my previous answer. It might work for this case but will
> > try
> > to decrypt many types of attachments which are in fact not pgp encrypted.
> > The attachment should have type
> > application/pgp-encrypted
> >
> > otherwise it needs to be fixed.
> >
> > Richard
> >
>
> --
> jm
>
Look at the mutt config here:
http://aperiodic.net/phil/configs/
Mostly look at the mailcap[1] and the script[2]. The mailcap file just
sends all octet-streams through a script which uses `file` to determine
the type of the file.
application/octet-stream; ~/bin/mutt.octet.filter %s; copiousoutput
I've attached the script (which looks to be under the GPL, so attaching
it here should be ok).
[1] http://aperiodic.net/phil/configs/mutt/mailcap
[2] http://aperiodic.net/phil/configs/bin/mutt.octet.filter
#!/bin/sh
#
# mutt.octet.filter - Octet filter for use with the mutt autoview facility
# Copyright (C) 1997,1998,1999,2000 David A Pearson
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# This script file is a pretty brain-dead, last resort, "works for me"
# utility that will attempt to make sense of any octet-stream data
# that is received as part of an email and act as a filter for use
# with mutt's auto_view ability.
#
# Here is how I use it. In my ~/.mutt_mailcap (use your filename of
# choice) I have the following entry:
#
# application/octet-stream; mutt.octet.filter %s; copiousoutput
#
# All you then need to do is add a line like:
#
# auto_view application/octet-stream
#
# to your ~/.muttrc (use your filename of choice).
#
# In it's current state the script isn't perfect, it's your typical
# "works for me" type of script and is offered in the hope that it
# maybe handy and that you can do something with it.
#
# All comments/flames/feedback can be directed to:
#
# [email protected]
#
# $Log: mutt.octet.filter,v $
# Revision 1.6 2000/05/10 13:34:19 davep
# Added patch from Aaron Schrab for handling RPM files.
#
# Revision 1.5 2000/02/28 15:28:13 davep
# Added support for .tar.bz2 files (thanks to Dirk Pirschel for that).
#
# Revision 1.4 1999/08/02 12:39:27 davep
# Minor nit-fix.
#
# Revision 1.3 1999/04/13 17:17:03 davep
# Added support for displaying .o files.
#
# Revision 1.2 1999/01/27 17:35:25 davep
# Added handling for .bz2 files (thanks to Lars Hecking for that).
# Added handling of MSWord documents (requires catdoc).
#
# Revision 1.1 1998/10/14 16:00:25 davep
# Initial revision
#
ShowTAR()
{
tar tvvf "$1" 2> /dev/null
}
ShowTGZ()
{
tar tzvvf "$1" 2> /dev/null
}
ShowTBZ()
{
bzip2 -dc "$1" | tar -tvv -f- 2> /dev/null
}
ShowGZIP()
{
gzip -dc "$1" 2> /dev/null
}
ShowBZIP()
{
bzip2 -dc "$1" 2> /dev/null
}
ShowZIP()
{
unzip -l "$1" 2> /dev/null
}
ShowARJ()
{
unarj l "$1" 2> /dev/null
}
ShowEXE()
{
echo $(basename "$1"): DOS/Windows executable
}
ShowOBJ()
{
echo $(basename "$1"): DOS/Windows object file
}
ShowLIB()
{
echo $(basename "$1"): MS-DOS program library
}
ShowNG()
{
echo $(basename "$1"): Norton Guide Database
}
ShowVCard()
{
cat "$1" | mutt.vcard.filter
}
ShowTIF()
{
tiffinfo "$1"
}
ShowMSWord()
{
wvHtml "$1" - 2>/dev/null | w3m -T text/html -cols 80 -dump
}
ShowMSExcel()
{
xlhtml %s 2>/dev/null | w3m -T text/html -cols 80 -dump
}
ShowObject()
{
nm "$1"
}
ShowRPM()
{
rpm -qip "$1"
}
ShowPDF()
{
pdftotext "$1" -
}
ShowData()
{
echo $(basename "$1"): unprintable data
}
DisplayFileType()
{
echo "[-- $(basename $0) file type: \"$1\" --]"
echo
}
ShowFileType()
{
FILE_TYPE=$(echo $(file "$1" 2> /dev/null) | cut -d' ' -f 2-)
DisplayFileType "$FILE_TYPE"
}
ShowMISC()
{
FILE_TYPE=$(file -z "$1" 2> /dev/null)
if [ $? -gt 0 ]
then
FILE_TYPE=$(file "$1" 2> /dev/null)
fi
FILE_TYPE=$(echo "$FILE_TYPE" | cut -d' ' -f 2-)
DisplayFileType "$FILE_TYPE"
case "$FILE_TYPE" in
*tar*archive*gzip* ) ShowTGZ "$1";;
*tar*archive* ) ShowTAR "$1";;
*gzip* ) ShowGZIP "$1";;
*ARJ*archive*data* ) ShowARJ "$1.";; # "." gets round bug in unarj.
*zip*archive*file* ) ShowZIP "$1";;
*DOS*executable* ) ShowEXE "$1";;
*ascii*text* ) cat "$1";;
*c*program*text* ) cat "$1";;
*8086*reloc*Micro* ) ShowOBJ "$1";;
*MS-DOS*prog*lib* ) ShowLIB "$1";;
PDF*document* ) ShowPDF "$1";;
data ) ShowData "$1";;
* ) cat "$1";;
esac
}
if [ "$1" = "" ]
then
echo "syntax: $(basename '$0') file"
else
case "$1" in
*.tar ) ShowFileType "$1"; ShowTAR "$1";;
*.tgz ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.gz ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.Z ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.z ) ShowFileType "$1"; ShowTGZ "$1";;
*.tbz2 ) ShowFileType "$1"; ShowTBZ "$1";;
*.tar.bz2 ) ShowFileType "$1"; ShowTBZ "$1";;
*.Z ) ShowFileType "$1"; ShowGZIP "$1";;
*.z ) ShowFileType "$1"; ShowGZIP "$1";;
*.gz ) ShowFileType "$1"; ShowGZIP "$1";;
*.bz2 ) ShowFileType "$1"; ShowBZIP "$1";;
*.zip ) ShowFileType "$1"; ShowZIP "$1";;
*.ZIP ) ShowFileType "$1"; ShowZIP "$1";;
*.arj ) ShowFileType "$1"; ShowARJ "$1";;
*.ARJ ) ShowFileType "$1"; ShowARJ "$1";;
*.log ) ShowFileType "$1"; cat "$1";;
*.LOG ) ShowFileType "$1"; cat "$1";;
*.obj ) ShowFileType "$1"; ShowOBJ "$1";;
*.OBJ ) ShowFileType "$1"; ShowOBJ "$1";;
*.lib ) ShowFileType "$1"; ShowLIB "$1";;
*.LIB ) ShowFileType "$1"; ShowLIB "$1";;
*.NG ) ShowFileType "$1"; ShowNG "$1";;
*.ng ) ShowFileType "$1"; ShowNG "$1";;
*.vcf ) ShowFileType "$1"; ShowVCard "$1";;
*.tif ) ShowFileType "$1"; ShowTIF "$1";;
*.TIF ) ShowFileType "$1"; ShowTIF "$1";;
*.doc ) ShowFileType "$1"; ShowMSWord "$1";;
*.DOC ) ShowFileType "$1"; ShowMSWord "$1";;
*.xls) ShowFileType "$1"; ShowMSExcel "$1";;
*.XLS) ShowFileType "$1"; ShowMSExcel "$1";;
*.o ) ShowFileType "$1"; ShowObject "$1";;
*.rpm ) ShowFileType "$1"; ShowRPM "$1";;
*.pdf ) ShowFileType "$1"; ShowPDF "$1";;
* ) ShowMISC "$1";;
esac
fi