commit b09b3d2249a4efc75624dbb6e1ebc375328c9d12
parent 0f8c27918d0dbc11d5577180f8cf1a6c473da7af
Author: Luke <luke@lukesmith.xyz>
Date: Wed, 14 Feb 2018 14:58:02 -0700
mailbox detect now searches all accounts
Diffstat:
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/mutt-wizard.sh b/mutt-wizard.sh
@@ -9,6 +9,8 @@ changePassword() { \
shred -u /tmp/$1
mv /tmp/$1.gpg ~/.config/mutt/credentials/ ;}
+chooseDetect() { for x in $(cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;'); do detectMailboxes $x; done && detectSuccess ;}
+
detectWarning() { \
dialog --title "Mailbox detect requirement" --yesno "In order for the mailbox detection system to work, you must have
@@ -53,15 +55,17 @@ detectMailboxes() { \
echo "set record = \"$record\"" >> "$muttdir"accounts/$1.muttrc
echo "set postponed = \"$postponed\"" >> "$muttdir"accounts/$1.muttrc ;}
-# Sees what accounts have been generated bny the wizard
-# by checking ~/.offlineimap and yields a menu of them.
-inventory() { \
+# Get all accounts in ~/.offlineimaprc and load into variable `accounts`.
+getAccounts() { \
cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered
accounts=()
while read n s ; do
accounts+=($n "$s" off)
- done < /tmp/numbered
+ done < /tmp/numbered ;}
+# Yields a menu of available accounts.
+inventory() { \
+ getAccounts
choices=$(dialog --separate-output --checklist "Choose an email account." 15 40 16 "${accounts[@]}" 2>&1 >/dev/tty)
if [ -z "$choices" ];
@@ -193,10 +197,10 @@ case $choice in
$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
" 6 60;;
1) addChosen;;
-2) detectWarning && inventory && for i in $userchoices; do detectMailboxes $i ; done && detectSuccess;;
+2) detectWarning && chooseDetect ;;
3) inventory && for i in $userchoices; do changePassword $i ; done;;
4) inventory && for i in $userchoices; do removeAccount $i ; done;;
5) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
-6) clear && break
+6) clear && break ;;
esac
done