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 /mutt/message_filter.sh | |
parent | a1eaadf3e7e9a538a489035cbd03baaa7ef79ff7 (diff) |
Add message filter
Diffstat (limited to 'mutt/message_filter.sh')
-rwxr-xr-x | mutt/message_filter.sh | 15 |
1 files changed, 15 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}" | ||