"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.6.2/tools/metamutt" (23 Aug 2021, 3816 Bytes) of package /linux/misc/tin-2.6.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/sh
    2 #
    3 # $ Id: metamutt,v 1.17 2000/02/23 12:50:41 roland Exp $
    4 #
    5 # This should become a replacement of metamail, using the mail reader
    6 # mutt. The options of metamail are not yet implemented, but it should
    7 # work as a filter without any problems.
    8 # 
    9 # This script was written to use it in combination with the tin news
   10 # reader, where you have to set the environment variable
   11 # METAMAIL=metamutt, but it should work with other programs, too.
   12 #
   13 # You need formail (from the procmail package) to use this script. If
   14 # you don't want to install formail, you will find an alternative
   15 # solution (commented out) below.
   16 #
   17 # Pressing "g" allows you to post a Followup to a newsgroup.
   18 #
   19 # Options:
   20 #  -D allows splits a digest into separate mails by using formail
   21 #     (Feature added by Martin Ramsch <m.ramsch@computer.org>)
   22 #
   23 # This script tries to find a working muttrc (which is sourced first)
   24 # at the following places (descending priority): 
   25 # 1) ~/.mutt/metamuttrc
   26 # 2) ~/.mutt/muttrc
   27 # 3) ~/.muttrc
   28 #
   29 # Most recent version can be found at http://www.spinnaker.de/mutt/metamutt
   30 #
   31 # Many thanks for reporting bugs and introducing new features to
   32 # Moritz Barsnick, Ulli Horlacher, Urs Janßen, and Martin Ramsch.
   33 #
   34 ##########################################################################
   35 #
   36 #   Copyright (C) 1997-2000  Roland Rosenfeld <roland@spinnaker.de>
   37 #
   38 #   This program is free software; you can redistribute it and/or
   39 #   modify it under the terms of the GNU General Public License as
   40 #   published by the Free Software Foundation; either version 2 of
   41 #   the License, or (at your option) any later version.
   42 #
   43 #   This program is distributed in the hope that it will be useful,
   44 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   45 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   46 #   General Public License for more details.
   47 #
   48 #   You should have received a copy of the GNU General Public License
   49 #   along with this program; if not, write to the Free Software
   50 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   51 #
   52 ##########################################################################
   53 
   54 umask 077
   55 
   56 tmpdir=${TMPDIR-/tmp}/metamutt.$$
   57 mkdir $tmpdir || exit 1
   58 trap "rm -rf $tmpdir; exit" 0 1 2 3 15
   59 
   60 # formail options:
   61 fmopt=''
   62 
   63 # do we read a digest?
   64 digest='no'
   65 
   66 # handle options (ignore most of them at the moment):
   67 for parameter 
   68 do
   69     case $1 in 
   70         -- ) shift; break;;
   71         -e|-p ) shift;;
   72         -m ) shift 2;;
   73     -D ) fmopt='-ds cat'
   74          digest='yes'
   75          shift;;
   76         * )  break;;
   77     esac
   78 done
   79 
   80 # create mbox message using formail (from procmail package):
   81 cat "$@" | formail $fmopt > $tmpdir/mbox
   82 
   83 # If you don't have formail installed, try this:
   84 #echo "From PIPE `env LC_ALL=C date`" > $tmpdir/mbox
   85 #cat $* - | sed 's/^From />From /' >> $tmpdir/mbox
   86 
   87 # create special muttrc for metamutt:
   88 for rcsuggestion in $HOME/.mutt/metamuttrc $HOME/.mutt/muttrc $HOME/.muttrc
   89 do
   90     if [ -f $rcsuggestion ]
   91     then
   92     echo "source $rcsuggestion" > $tmpdir/muttrc
   93     break
   94     fi
   95 done
   96 
   97 cat >> $tmpdir/muttrc <<EOF
   98 macro pager g ":set sendmail=$tmpdir/inews dsn_notify='' dsn_return=''<return>:my_hdr `formail -X Newsgroups < $tmpdir/mbox`<return>r"
   99 EOF
  100 
  101 # some additions, if we read exactly one article.
  102 if [ "$digest" = "no" ]
  103 then
  104 
  105 cat >> $tmpdir/muttrc <<EOF
  106 set pager_index_lines=0
  107 set quit=yes
  108 bind pager \t next-page
  109 bind pager i quit
  110 bind pager q quit
  111 bind pager x quit
  112 bind index q quit
  113 push "<return>"
  114 EOF
  115 
  116 fi
  117 
  118 # create special inews which removes mail only headers:
  119 cat > $tmpdir/inews<<EOF
  120 #! /bin/sh
  121 formail -I To -I Cc -I Bcc -I Fcc -I From\  -I In-Reply-To \
  122     -R X-Mailer User-Agent | inews -h
  123 EOF
  124 chmod 700 $tmpdir/inews
  125 
  126 # run mutt on mbox message with special muttrc:
  127 mutt -F $tmpdir/muttrc -f $tmpdir/mbox </dev/tty >/dev/tty