display (732B)
1 #!/bin/sh 2 3 MESSAGE=$(cat) 4 5 EMAIL=$(echo "${MESSAGE}" | grep ^"From: " | sed 's/[^<]*<\([^@]*\)@.*/\1/') 6 7 case $EMAIL in 8 "DO_NOT_REPLY") addalias=no;; 9 "drive-shares-noreply") addalias=no;; 10 noreply*|no-reply*|no_reply*) addalias=no;; 11 artifactory) addalias=no;; 12 *) addalias=yes;; 13 esac 14 15 if [ "$addalias" = "yes" ]; then 16 NEWALIAS=$(echo "${MESSAGE}" | grep ^"From: " | sed s/[\,\"\']//g | awk '{$1=""; if (NF == 3) {print "alias" $0;} else if (NF == 2) {print "alias" $0 $0;} else if (NF > 3) {print "alias", tolower($2)"-"tolower($(NF-1)) $0;}}') 17 if grep -Fxq "$NEWALIAS" "$HOME"/.config/mutt/alias; then 18 : 19 else 20 echo "$NEWALIAS" >> "$HOME"/.config/mutt/alias 21 fi 22 fi 23 24 echo "${MESSAGE}"