mutt-wizard

fork of Luke Smiths mutt-wizard
git clone git://git.jakekoroman.com/mutt-wizard
Log | Files | Refs | README | LICENSE

commit d3300a478d7a87800d9c2ccb78768b409ae660cf
parent fe23f7c6722ded6d6ee7823c63c4ebfc82e16d70
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Sat, 18 Feb 2023 17:11:54 -0500

simplification of decoding, show help on noopt

Diffstat:
Mbin/mailsync | 16++++++----------
Mbin/mw | 2++
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/bin/mailsync b/bin/mailsync @@ -70,16 +70,12 @@ syncandnotify() { echo "$newcount new mail for $2." [ -z "$MAILSYNC_MUTE" ] && for file in $new; do - # Extract subject and sender from mail. TODO: beautify and clean up. - from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | - perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | - awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | - sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//') - subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | - head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | - sed 's/^Subject: //' | - sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | - tr -d '\n') + # Extract and decode subject and sender from mail. + subject="$(sed -n "/^Subject:/ s|Subject: *|| p" "$file" | + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" + from="$(sed -n "/^From:/ s|From: *|| p" "$file" | + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" + from="${from% *}" ; from="${from%\"}" ; from="${from#\"}" notify "📧$from:" "$subject" done ;; diff --git a/bin/mw b/bin/mw @@ -313,6 +313,8 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:" o; do case "${o}" in \?) echo "See \`$(basename $0) -h\` for possible options and help."; exit 1 ;; esac done +[ -z "$action" ] && action="info" + case "$action" in list) list ;; add) checkbasics && askinfo && getboxes && getprofiles && finalize ;;