diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2022-11-12 00:12:51 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2022-11-12 00:12:51 +0800 |
commit | 23de972209f154c32890ca1700d7a047cdeda4dd (patch) | |
tree | d9fea3c8ceee7de5c32458868a9ea08fbd8fe264 | |
parent | a1eaadf3e7e9a538a489035cbd03baaa7ef79ff7 (diff) |
Add message filter
-rwxr-xr-x | mutt/message_filter.sh | 15 | ||||
-rw-r--r-- | mutt/muttrc.topo | 1 |
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 | |||
3 | cd $(dirname $0) | ||
4 | |||
5 | MESSAGE=$(cat) | ||
6 | |||
7 | 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;}}') | ||
8 | |||
9 | if grep -Fxq "$NEWALIAS" alias.topo; then | ||
10 | : | ||
11 | else | ||
12 | echo "$NEWALIAS" >> alias.topo | ||
13 | fi | ||
14 | |||
15 | 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 | |||
17 | set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id | 17 | set pgp_sign_as = 6DD8C14A # replace 6DD8C14A with your gpg key id |
18 | 18 | ||
19 | # Tune contacts | 19 | # Tune contacts |
20 | set display_filter = ~/.config/mutt/message_filter.sh | ||
20 | source ~/.config/mutt/alias.topo | 21 | source ~/.config/mutt/alias.topo |
21 | source ~/.config/mutt/hooks.topo | 22 | source ~/.config/mutt/hooks.topo |
22 | 23 | ||