diff options
author | Ryan Kavanagh <rak@debian.org> | 2013-07-25 08:35:01 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@debian.org> | 2013-07-25 08:45:10 -0400 |
commit | a25214a59552b315da0ae5de69f3d131977a4899 (patch) | |
tree | d6bb2e5f33a7370517ce2e98b0998171416f8a41 | |
parent | Added a python mutagen script for tagging my flacs (diff) |
Added a script to automatically add addresses to my mutt aliases
-rwxr-xr-x | bin/mutt-autoalias | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/mutt-autoalias b/bin/mutt-autoalias new file mode 100755 index 0000000..a9725d5 --- /dev/null +++ b/bin/mutt-autoalias @@ -0,0 +1,16 @@ +#!/bin/sh + +MESSAGE=$(cat) + +EXCLUDE="\(.*@bugs.\(debian.org|launchpad.net\)|.*@.*.launchpad.net|noreply|.*facebook.*|.*gmail.com.*Behalf Of\)" +NEWALIAS=$(echo "${MESSAGE}" | grep ^"From: " | egrep -v "${EXCLUDE}" | 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($(NF-1))"."tolower($2) $0;}}') + +if grep -Fxq "$NEWALIAS" $HOME/.mutt/alias.rc; then + : +elif [ "x${NEWALIAS}" = "x" ]; then + : +else + echo "$NEWALIAS" >> $HOME/.mutt/alias.rc +fi + +echo "${MESSAGE}" |