aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2022-11-12 00:12:51 +0800
committerHsieh Chin Fan <pham@topo.tw>2022-11-12 00:12:51 +0800
commit23de972209f154c32890ca1700d7a047cdeda4dd (patch)
treed9fea3c8ceee7de5c32458868a9ea08fbd8fe264
parenta1eaadf3e7e9a538a489035cbd03baaa7ef79ff7 (diff)
Add message filter
-rwxr-xr-xmutt/message_filter.sh15
-rw-r--r--mutt/muttrc.topo1
2 files changed, 16 insertions, 0 deletions
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 @@
1#!/bin/sh
2
3cd $(dirname $0)
4
5MESSAGE=$(cat)
6
7NEWALIAS=$(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;}}')
8
9if grep -Fxq "$NEWALIAS" alias.topo; then
10 :
11else
12 echo "$NEWALIAS" >> alias.topo
13fi
14
15echo "${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
17set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id 17set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id
18 18
19# Tune contacts 19# Tune contacts
20set display_filter = ~/.config/mutt/message_filter.sh
20source ~/.config/mutt/alias.topo 21source ~/.config/mutt/alias.topo
21source ~/.config/mutt/hooks.topo 22source ~/.config/mutt/hooks.topo
22 23