A while back, someone asked how to strip out signatures, etc. I posted a
little script which I've since improved. The included awk script can be
easily modified to include different types of signatures (advertisements,
etc.).

Here's the script in cace anyone's interested. Just change your editor to
'mutt-vim' in .muttrc. You'll have to edit the script and up date the vim
parameters etc. to your preferences.

LateR!
js.
-- 
Jean-Sebastien Morisset, Sr. UNIX Administrator <[EMAIL PROTECTED]>
Personal Homepage <http://jsmoriss.mvlan.net/>; UNIX, Internet, 
Homebrewing, Cigars, PCS, PalmOS, CP2020 and other Fun Stuff...
This is Linux Country. On a quiet night you can hear Windows NT reboot!
#!/bin/sh

clear
umask 077

Vim () { vim "+set nonu" "+set wm=6" "+set ai" "+set ts=8" $* }

# strip signatures
if [ -x "`which gawk 2>/dev/null`" -a -s "$1" ]
then
        gawk '
        # compress indent strings from "> > > " to ">>> "
        function compress_indent_string() { 
                while ($0 ~ /^>+ >( ?|$)/) { sub(/> >( ?|$)/, ">> ") }
        }
        function remove_signature() {
                # remove all consecutive non-blank lines
                # the first blank line signals the end of the signature
                while ($0 !~ /^(>+ ?|)$/) { getline; compress_indent_string() }
                # remove blank lines after the the signature
                while ($0 ~ /^(>+ ?|)$/) { getline; compress_indent_string() }
        }
        { 
                compress_indent_string()
                if ($0 ~ /^>+ --( ?|--*)$/) { remove_signature() }
                if ($0 ~ /^>+ ------------------------ Yahoo! Groups Sponsor /) { 
remove_signature() }
                if ($0 ~ /^>+ To unsubscribe from this group, send an email to:$/) { 
remove_signature() }
                if ($0 ~ /^>+ Your use of Yahoo! Groups is subject to/) { 
remove_signature() }
                print $0 > OUTFILE
        }' OUTFILE=$1.out $1 && mv $1.out $1
fi

case $LOGNAME in
        root|jsmoriss)
                case $SSH_CLIENT in
                        "10.1.1.120 "*) stty cols 80; Vim $*; stty cols 132 ;;
                        "38.144."*)     stty cols 80; Vim $*; stty cols 132 ;;
                        "64."*) stty cols 80; Vim $*; stty cols 132 ;;
                        *)      Vim $* ;;
                esac
                ;;
        *)      Vim $* ;;
esac

PGP signature

Reply via email to