diff options
-rwxr-xr-x | bin/mw | 23 | ||||
-rw-r--r-- | share/mutt-wizard.muttrc | 5 |
2 files changed, 12 insertions, 16 deletions
@@ -13,7 +13,6 @@ pass_prefix="mw-" muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage -namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" @@ -48,7 +47,7 @@ port ${sport:-587} from $fulladdr user $login passwordeval \"pass $pass_prefix$fulladdr\" -$starttlsoff +$tlsline " mbsync_profile="IMAPStore $fulladdr-remote Host $imap @@ -170,7 +169,7 @@ askinfo() { \ read -r imap [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && read -r smtp - [ "$sport" = 465 ] && starttlsoff="tls_starttls off" + [ "$sport" = 465 ] && tlsline="tls_starttls off" [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && read -r realname login="${login:-$fulladdr}" @@ -210,10 +209,6 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ notmuchauto # Create a notmuch config file if not present already. } -protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" - fingerprint="$(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | grep SHA256: | sed 's/^.*: //')" - sed -ibu "s/account $fulladdr/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu ;} - getpass() { while : ; do pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 pass insert "$pass_prefix$fulladdr" && break; done ;} @@ -232,7 +227,7 @@ Trash Sent Archive" && return 0 if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu + [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu return 0 else echo "$mailboxes" @@ -294,7 +289,7 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then trap 'echo -e "\033[0m\n"; exit' INT ABRT -while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in +while getopts "fplhodYD:y:i:I:s:S:u:a:n:x:m:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -312,13 +307,12 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." - proton=True imap="127.0.0.1" iport="1143" smtp="127.0.0.1" sport="1025" ssltype="None" - protonfinger + tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" setact add || exit 1 ;; *) cat << EOF @@ -334,12 +328,13 @@ Main actions: -Y Sync mail for all accounts Options allowed with -a: - -u Account login name if not full address. - -n "Real name" to be on the email account. + -u Account login name if not full address + -n "Real name" to be on the email account -i IMAP server address -I IMAP server port -s SMTP server address -S SMTP server port + -x Password for account (recommended to be in double quotes) -p Install for a Protonmail account. -o Configure address, but keep mail online. -b Assume typical English mailboxes without attempting log-on. @@ -357,7 +352,7 @@ esac done case "$action" in list) list ;; - add) askinfo && getprofiles && writeinfo && getboxes && finalize || delete ;; + add) askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; delete) delete $fulladdr ;; sync) syncwrapper $fulladdr ;; esac diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index de169db..94401e8 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -22,8 +22,9 @@ set forward_quote # include message in forwards set reverse_name # reply as whomever it was to set include # include message in replies set mail_check=60 # to avoid lags using IMAP with some email providers (yahoo for example) -auto_view text/html # automatically show html (mailcap uses w3m) +auto_view text/html # automatically show html (mailcap uses lynx) auto_view application/pgp-encrypted +set display_filter = "tac | sed '/\\\[-- Autoview/,+1d' | tac" # Suppress autoview messages. alternative_order text/plain text/enriched text/html bind index,pager i noop bind index,pager g noop @@ -70,7 +71,7 @@ bind editor <Tab> complete-query macro index,pager a "<enter-command>set my_pipe_decode=\$pipe_decode pipe_decode<return><pipe-message>abook --add-email<return><enter-command>set pipe_decode=\$my_pipe_decode; unset my_pipe_decode<return>" "add the sender address to abook" macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read" -macro index O "<shell-escape>mbsync -a<enter>" "run mbsync to sync all mail" +macro index O "<shell-escape>mw -Y<enter>" "run mw -Y to sync all mail" macro index \Cf "<enter-command>unset wait_key<enter><shell-escape>printf 'Enter a search term to find with notmuch: '; read x; echo \$x >~/.cache/mutt_terms<enter><limit>~i \"\`notmuch search --output=messages \$(cat ~/.cache/mutt_terms) | head -n 600 | perl -le '@a=<>;s/\^id:// for@a;$,=\"|\";print@a' | perl -le '@a=<>; chomp@a; s/\\+/\\\\+/ for@a;print@a' \`\"<enter>" "show only messages matching a notmuch pattern" macro index A "<limit>all\n" "show all messages (undo limit)" |