diff options
author | Luke <luke@lukesmith.xyz> | 2018-02-13 12:15:43 -0700 |
---|---|---|
committer | Luke <luke@lukesmith.xyz> | 2018-02-13 12:15:43 -0700 |
commit | 6f6802313340ba7ed152f0953e1e0a1a43fbd394 (patch) | |
tree | e3905fad3f7f081f8f7fd3d9e97b8d9a94b52038 /mutt-wizard.sh | |
parent | d77d46a97c47cafc594310145256a0e3c24490dc (diff) |
mailbox wizard added
Diffstat (limited to 'mutt-wizard.sh')
-rwxr-xr-x | mutt-wizard.sh | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/mutt-wizard.sh b/mutt-wizard.sh index 08f7512..710ce5b 100755 --- a/mutt-wizard.sh +++ b/mutt-wizard.sh @@ -2,6 +2,25 @@ muttdir="$HOME/.config/mutt/" +formatShortcut() { \ + while read data; do + echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\"" >> "$muttdir"accounts/$3.muttrc + done ;} + + +detectMailboxes() { \ + find ~/.mail/$1 -maxdepth 1 -mindepth 1 -type d | sed -e "s/.*\///g;s/^/=/g" > /tmp/$1_boxes + oneline=$(cat /tmp/$1_boxes | tr "\n" " ") + sed -i "/^mailboxes/d" "$muttdir"accounts/$1.muttrc + echo mailboxes $oneline >> "$muttdir"accounts/$1.muttrc + sed -i "/^macro index,pager g/d" "$muttdir"accounts/$1.muttrc + grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|junk\|archive" | sort -n | sed 1q | formatShortcut i inbox $1 + grep -i /tmp/$1_boxes -e sent | formatShortcut s sent $1 + grep -i /tmp/$1_boxes -e trash | formatShortcut t trash $1 + grep -i /tmp/$1_boxes -e spam | formatShortcut S spam $1 + grep -i /tmp/$1_boxes -e draft | formatShortcut d drafts $1 + grep -i /tmp/$1_boxes -e archive | formatShortcut a archive $1 ;} + # Sees what accounts have been generated bny the wizard # by checking ~/.offlineimap and yields a menu of them. inventory() { \ @@ -132,12 +151,13 @@ wipe () { rm $HOME/.offlineimaprc while : ; do choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" \ - --menu "What would you like to do?" 14 45 5 \ + --menu "What would you like to do?" 13 45 6 \ 0 "List all email accounts configured." \ 1 "Add an email account." \ - 2 "Remove an email account." \ - 3 "Remove all email accounts." \ - 4 "Exit this wizard." \ + 2 "Auto-detect mailboxes for an account." \ + 3 "Remove an email account." \ + 4 "Remove all email accounts." \ + 5 "Exit this wizard." \ 3>&1 1>&2 2>&3 3>&1 ) @@ -146,8 +166,9 @@ case $choice in $(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g') " 6 60;; 1) addChosen;; -2) inventory && for i in $userchoices; do removeAccount $i ; done;; -3) (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) ;; -4) clear && break +2) inventory && for i in $userchoices; do detectMailboxes $1 ; done &&exit;; +3) inventory && for i in $userchoices; do removeAccount $i ; done;; +4) (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) ;; +5) clear && break esac done |