commit c08cfd53654bb3046502955c93399861b487c760
parent d1c4a8eb1096219560f707fbc60a9c0d09e0f27f
Author: Luke Smith <luke@lukesmith.xyz>
Date: Sun, 11 Oct 2020 19:29:34 -0400
more
Diffstat:
2 files changed, 11 insertions(+), 41 deletions(-)
diff --git a/bin/mw b/bin/mw
@@ -94,7 +94,7 @@ bind index,pager g noop
bind index,pager M noop
bind index,pager C noop
bind index gg first-entry
-macro index o \"<shell-escape>mbsync -V $fulladdr<enter>\" \"run mbsync to sync $fulladdr\"
+macro index o \"<shell-escape>mw -y $fulladdr<enter>\" \"run mbsync to sync $fulladdr\"
unmailboxes *
"
else
@@ -182,42 +182,31 @@ askinfo() { \
}
-writeinfo() {
- # Insert account information into variables.
- getprofiles
-
- # Create required directories.
- mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr"
+writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr"
# Get accounts and find the first missing account number (max. 9).
getaccounts
for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done
- # Create msmtprc file if not present.
+ # Configure msmtprc for sending mail.
[ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc"
-
- # Add account msmtp settings.
echo "$msmtp_profile" >> "$msmtprc"
-
# On Ubuntu/Debian, a link is needed since they use an older version.
command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null
- # Create the individual mutt config file for the account.
- echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc"
-
# Create the mbsync config file.
mkdir -p "${mbsyncrc%/*}"
echo "$mbsync_profile" >> "$mbsyncrc"
- # Create a notmuch config file if not present already.
- notmuchauto
-
- # Create a basic muttrc is not present and source the mutt-wizard files
- # and add the shortcuts to the account.
- [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created."
+ # Create a muttrc for viewing mail.
+ echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc"
+ [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc"
! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $MARKER" >> "$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" $MARKER" >> "$muttrc"
+
+ # Create a notmuch config file if not present already.
+ notmuchauto
}
protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n"
@@ -269,30 +258,12 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur
command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview"
return 0 ;}
-confirm() { printf "Do you want to %s? [yes/N]\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
- printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
- return 0 ;}
-
-pick() { [ -n "${fulladdr+x}" ] && return 0
- echo "Select the account your would like to $1 (by number):"
- list
- read -r input
- fulladdr="$(echo "$accounts" | grep "^$input:" | cut -f2 -d' ')"
- [ -z "$fulladdr" ] && echo "Invalid response." && return 1
- return 0 ;}
-
syncwrapper() { mbsync "${1:--a}" &
( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
wait
( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
notmuch new ;}
-purge() { confirm "delete all account data" || exit
- rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir"
- echo "All configs and account settings have been purged."
- sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu
-}
-
notmuchauto() { \
[ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config"
[ -f "$NOTMUCH_CONFIG" ] && return 0
@@ -384,8 +355,7 @@ esac done
case "$action" in
list) list ;;
- add) askinfo && writeinfo && getboxes && finalize || delete ;;
+ add) askinfo && getprofiles && writeinfo && getboxes && finalize || delete ;;
delete) delete $fulladdr ;;
sync) syncwrapper $fulladdr ;;
- purge) purge ;;
esac
diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc
@@ -80,7 +80,7 @@ set sidebar_width = 20
set sidebar_short_path = yes
set sidebar_next_new_wrap = yes
set mail_check_stats
-set sidebar_format = '%B%?F? [%F]?%* %?N?%N/? %?S?%S?'
+set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?'
bind index,pager \Ck sidebar-prev
bind index,pager \Cj sidebar-next
bind index,pager \Co sidebar-open