| @@ -211,31 +211,31 @@ trysync() { \ | |||||
| } | } | ||||
| finalize() { \ | finalize() { \ | ||||
| boxes="$(ls -d "$maildir/$1/"* 2>/dev/null | sed "s/.*\///;s/^/=/")" | |||||
| [ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that offlineimap has not been successfully run.\\nRun offlineimap, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$1" && exit | |||||
| echo "$boxes" > "$tmpdir/$1_boxes" | |||||
| boxes="$(ls -d "$maildir/$title/"* 2>/dev/null | sed "s/.*\///;s/^/=/")" | |||||
| [ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that offlineimap has not been successfully run.\\nRun offlineimap, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && exit | |||||
| echo "$boxes" > "$tmpdir/$title_boxes" | |||||
| printf "Setting up the mutt sidebar...\\n" | printf "Setting up the mutt sidebar...\\n" | ||||
| sidebar_width="$(sed -n -e '/^set sidebar_width/p' "$muttdir/muttrc" | awk -F'=' '{print $2}')" | sidebar_width="$(sed -n -e '/^set sidebar_width/p' "$muttdir/muttrc" | awk -F'=' '{print $2}')" | ||||
| delim="$(gen_delim "$sidebar_width")" | delim="$(gen_delim "$sidebar_width")" | ||||
| printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" | printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" | ||||
| oneline="$(sed -e "s/^\|$/\"/g" "$tmpdir/$1_boxes" | tr "\n" " ")" | |||||
| oneline="=$1 $delim $oneline" | |||||
| spoolfile=$(grep -i "$tmpdir/$1_boxes" -e inbox | sed -e 's/=/+/g' | sed 1q) | |||||
| record=$(grep -i "$tmpdir/$1_boxes" -e sent | sed -e 's/=/+/g' | sed 1q) | |||||
| postponed=$(grep -i "$tmpdir/$1_boxes" -e draft | sed -e 's/=/+/g' | sed 1q) | |||||
| trash=$(grep -i "$tmpdir/$1_boxes" -e trash | sed -e 's/=/+/g' | sed 1q) | |||||
| { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$muttdir/accounts/$1.muttrc" | |||||
| sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$muttdir/accounts/$1.muttrc" | |||||
| echo mailboxes "$oneline" >> "$muttdir/accounts/$1.muttrc" | |||||
| oneline="$(sed -e "s/^\|$/\"/g" "$tmpdir/$title_boxes" | tr "\n" " ")" | |||||
| oneline="=$title $delim $oneline" | |||||
| spoolfile=$(grep -i "$tmpdir/$title_boxes" -e inbox | sed -e 's/=/+/g' | sed 1q) | |||||
| record=$(grep -i "$tmpdir/$title_boxes" -e sent | sed -e 's/=/+/g' | sed 1q) | |||||
| postponed=$(grep -i "$tmpdir/$title_boxes" -e draft | sed -e 's/=/+/g' | sed 1q) | |||||
| trash=$(grep -i "$tmpdir/$title_boxes" -e trash | sed -e 's/=/+/g' | sed 1q) | |||||
| { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$muttdir/accounts/$title.muttrc" | |||||
| sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$muttdir/accounts/$title.muttrc" | |||||
| echo mailboxes "$oneline" >> "$muttdir/accounts/$title.muttrc" | |||||
| printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" | printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" | ||||
| sed -i "/# autogenerated/d" "$muttdir/accounts/$1.muttrc" | |||||
| grep -i "$tmpdir/$1_boxes" -e inbox | sed 1q | formatShortcut i inbox "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e sent | sed 1q | formatShortcut s sent "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e draft | sed 1q | formatShortcut d drafts "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e trash | sed 1q | formatShortcut t trash "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e spam | sed 1q | formatShortcut S spam "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e junk | sed 1q | formatShortcut j junk "$1" | |||||
| grep -i "$tmpdir/$1_boxes" -e archive | sed 1q | formatShortcut a archive "$1" | |||||
| sed -i "/# autogenerated/d" "$muttdir/accounts/$title.muttrc" | |||||
| grep -i "$tmpdir/$title_boxes" -e inbox | sed 1q | formatShortcut i inbox "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e sent | sed 1q | formatShortcut s sent "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e draft | sed 1q | formatShortcut d drafts "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e trash | sed 1q | formatShortcut t trash "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e spam | sed 1q | formatShortcut S spam "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e junk | sed 1q | formatShortcut j junk "$title" | |||||
| grep -i "$tmpdir/$title_boxes" -e archive | sed 1q | formatShortcut a archive "$title" | |||||
| printf "All done.\\n" | printf "All done.\\n" | ||||
| } | } | ||||
| @@ -243,11 +243,14 @@ finalize() { \ | |||||
| [ -z "$gpgemail" ] && askgpg | [ -z "$gpgemail" ] && askgpg | ||||
| select() { \ | |||||
| pick() { \ | |||||
| grep "^accounts *=" "$HOME/.config/offlineimap/config" | sed 's/accounts *= *//g;s/,/ /g;s/ \+/\n/g' | nl > "$tmpdir/numbered" | grep "^accounts *=" "$HOME/.config/offlineimap/config" | sed 's/accounts *= *//g;s/,/ /g;s/ \+/\n/g' | nl > "$tmpdir/numbered" | ||||
| cat "$tmpdir/numbered" | cat "$tmpdir/numbered" | ||||
| print "Select (an) account(s) to %s.\\n" "$1" | print "Select (an) account(s) to %s.\\n" "$1" | ||||
| read -r input | read -r input | ||||
| title="$(cat "$tmpdir/numbered" | grep "$input" | awk '{print $2}')" | |||||
| [ -z "$title" ] && printf "Invalid response." && exit 1 | |||||
| [ ! -z "$2" ] && printf "Are you sure you want to %s the \`%s\` account?" "$1" "$title" && read -r input && echo "$input" | grep -i "y\(es\)*" >/dev/null | |||||
| } | } | ||||
| removeAccount() { sed -ie " | removeAccount() { sed -ie " | ||||
| @@ -275,7 +278,7 @@ Input a number to continue or press ctrl-c.\\n" | |||||
| read -r choice | read -r choice | ||||
| case "$choice" in | case "$choice" in | ||||
| 1) addaccount ;; | 1) addaccount ;; | ||||
| 2) finalize ;; | |||||
| 2) pick delete yes && finalize "$title" ;; | |||||
| 0) break ;; | 0) break ;; | ||||
| *) printf "Invalid input.\\n" | *) printf "Invalid input.\\n" | ||||
| esac | esac | ||||