From 23de972209f154c32890ca1700d7a047cdeda4dd Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sat, 12 Nov 2022 00:12:51 +0800 Subject: Add message filter --- mutt/message_filter.sh | 15 +++++++++++++++ mutt/muttrc.topo | 1 + 2 files changed, 16 insertions(+) create mode 100755 mutt/message_filter.sh diff --git a/mutt/message_filter.sh b/mutt/message_filter.sh new file mode 100755 index 0000000..2b4db0e --- /dev/null +++ b/mutt/message_filter.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cd $(dirname $0) + +MESSAGE=$(cat) + +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($(NF-1))"-"tolower($2) $0;}}') + +if grep -Fxq "$NEWALIAS" alias.topo; then + : +else + echo "$NEWALIAS" >> alias.topo +fi + +echo "${MESSAGE}" diff --git a/mutt/muttrc.topo b/mutt/muttrc.topo index a95825d..5c2a9b9 100644 --- a/mutt/muttrc.topo +++ b/mutt/muttrc.topo @@ -17,6 +17,7 @@ set pgp_timeout = 300 set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id # Tune contacts +set display_filter = ~/.config/mutt/message_filter.sh source ~/.config/mutt/alias.topo source ~/.config/mutt/hooks.topo -- cgit v1.2.3-70-g09d2