#! /bin/sh # # $ Id: metamutt,v 1.15 1999/01/20 13:53:10 roland Exp $ # # This should become a replacement of metamail, using the mail reader # mutt. The options of metamail are not yet implemented, but it should # work as a filter without any problems. # # This script was written to use it in combination with the tin news # reader, where you have to set the envionment variable # METAMAIL=metamutt, but it should work with other programs, too. # # You need formail (from the procmail package) to use this script. If # you don't want to install formail, you will find an alternative # solution (commented out) below. # # Pressing "g" allows you to post a Followup to a newsgroup. # # Options: # -D allows splits a digest into seperate mails by using formail # (Feature added by Martin Ramsch ) # # This script tries to find a working muttrc (which is sourced first) # at the following places (descending priority): # 1) ~/.mutt/metamuttrc # 2) ~/.mutt/muttrc # 3) ~/.muttrc # # Most recent version can be found at http://www.rhein.de/~roland/mutt/metamutt # ########################################################################## # # Copyright (C) 1997-1999 Roland Rosenfeld # # 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. # umask 077 tmpdir=${TMPDIR-/tmp}/metamutt.$$ mkdir $tmpdir || exit 1 trap "rm -rf $tmpdir; exit" 0 1 2 3 15 # formail options: fmopt='' # do we read a digest? digest='no' # handle options (ignore most of them at the moment): for parameter do case $1 in -- ) shift; break;; -e|-p ) shift;; -m ) shift 2;; -D ) fmopt='-ds cat' digest='yes' shift;; * ) break;; esac done # create mbox message using formail (from procmail package): cat "$@" | formail $fmopt > $tmpdir/mbox # If you don't have formail installed, try this: #echo "From PIPE `env LC_ALL=C date`" > $tmpdir/mbox #cat $* - | sed 's/^From />From /' >> $tmpdir/mbox # create special muttrc for metamutt: if [ -f ~/.mutt/metamuttrc ] then echo 'source ~/.mutt/metamuttrc' > $tmpdir/muttrc elif [ -f ~/.mutt/muttrc ] then echo 'source ~/.mutt/muttrc' > $tmpdir/muttrc elif [ -f ~/.muttrc ] then echo 'source ~/.muttrc' > $tmpdir/muttrc fi cat >> $tmpdir/muttrc <: my_hdr `formail -X Newsgroups < $tmpdir/mbox`r" EOF # some additions, if we read exactly one article. if [ "$digest" = "no" ] then cat >> $tmpdir/muttrc <" EOF fi # create special inews which removes mail only headers: cat > $tmpdir/inews</dev/tty