| @@ -186,30 +186,27 @@ tryconnect() { mkdir -p "$maildir/$title" | |||
| finalize() { \ | |||
| boxes="$(du -a "$maildir/$title/"* -d 0 | sed "s/^.*\//=/")" | |||
| [ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && return | |||
| tmpdir="$(mktemp -d)" | |||
| echo "$boxes" > "$tmpdir/title_boxes" | |||
| printf "Setting up the mutt sidebar...\\n" | |||
| sidebar_width="$(sed -n -e '/^set sidebar_width/p' "$muttdir/muttrc" | awk -F'=' '{print $2}')" | |||
| delim="$(head -c "$sidebar_width" < /dev/zero | tr '\0' =)" | |||
| printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" | |||
| oneline="$(sed -e "s/^\|$/\"/g" "$tmpdir/title_boxes" | tr "\n" " ")" | |||
| oneline="=$title $delim $oneline" | |||
| spoolfile=$(grep -i -m 1 "$tmpdir/title_boxes" -e inbox | sed -e 's/=/+/g') | |||
| record=$(grep -i -m 1 "$tmpdir/title_boxes" -e sent | sed -e 's/=/+/g') | |||
| postponed=$(grep -i -m 1 "$tmpdir/title_boxes" -e draft | sed -e 's/=/+/g') | |||
| trash=$(grep -i -m 1 "$tmpdir/title_boxes" -e trash | sed -e 's/=/+/g') | |||
| oneline="=$title $delim $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" | |||
| spoolfile=$(echo "$boxes" | grep -i -m 1 inbox | sed 's/=/+/g') | |||
| record=$(echo "$boxes" | grep -i -m 1 sent | sed 's/=/+/g') | |||
| postponed=$(echo "$boxes" | grep -i -m 1 draft | sed 's/=/+/g') | |||
| trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g') | |||
| sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" | |||
| { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc" | |||
| echo mailboxes "$oneline" >> "$accdir/$idnum-$title.muttrc" | |||
| printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" | |||
| sed -i "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" | |||
| grep -i -m 1 inbox "$tmpdir/title_boxes" | formatShortcut i inbox | |||
| grep -i -m 1 sent "$tmpdir/title_boxes" | formatShortcut s sent | |||
| grep -i -m 1 draft "$tmpdir/title_boxes" | formatShortcut d drafts | |||
| grep -i -m 1 trash "$tmpdir/title_boxes" | formatShortcut t trash | |||
| grep -i -m 1 spam "$tmpdir/title_boxes" | formatShortcut S spam | |||
| grep -i -m 1 junk "$tmpdir/title_boxes" | formatShortcut j junk | |||
| grep -i -m 1 archive "$tmpdir/title_boxes" | formatShortcut a archive | |||
| echo "$boxes" | grep -i -m 1 inbox | formatShortcut i inbox | |||
| echo "$boxes" | grep -i -m 1 sent | formatShortcut s sent | |||
| echo "$boxes" | grep -i -m 1 draft | formatShortcut d drafts | |||
| echo "$boxes" | grep -i -m 1 trash | formatShortcut t trash | |||
| echo "$boxes" | grep -i -m 1 spam | formatShortcut S spam | |||
| echo "$boxes" | grep -i -m 1 junk | formatShortcut j junk | |||
| echo "$boxes" | grep -i -m 1 archive | formatShortcut a archive | |||
| [ "$accounttype" = "offline" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title" | |||
| } | |||
| @@ -261,18 +258,17 @@ asktype() { while : ; do | |||
| *) echo "Write out either yes or no completely. Try again or press ctrl-c to quit." ;; | |||
| esac; done ;} | |||
| init() { echo "Initializing a mutt-wizard configuration..." | |||
| mkdir -p "$muttdir" "$accdir" && echo "Required directories created." | |||
| init() { mkdir -p "$muttdir" "$accdir" | |||
| [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." | |||
| cp -v "$muttshare/mailcap" "$muttdir" && echo "Mailcap file added." | |||
| cp -v "$muttshare/mutt-wizard.muttrc" "$muttdir" && echo "mutt-wizard config file added." | |||
| ! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig" >> "$muttrc" && echo "muttrc will now source mutt-wizard." | |||
| cp -f "$muttshare/mailcap" "$muttdir" && echo "Mailcap file added." | |||
| cp -f "$muttshare/mutt-wizard.muttrc" "$muttdir" && echo "mutt-wizard config file added." | |||
| ! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig # mw-autogenerated" >> "$muttrc" && echo "muttrc will now source mutt-wizard." | |||
| } | |||
| purge() { confirm "delete all account data" || exit | |||
| rm -rf "$mbsyncrc" "$accdir" "$mwconfig" "$HOME/.config/msmtp" "$mwconfig" | |||
| echo "All configs and account settings have been purged." | |||
| sed -i "\|$mwconfig|d" "$muttrc" | |||
| sed -i "/\# mw-autogenerated/d" "$muttrc" | |||
| } | |||
| case "$1" in | |||
| @@ -300,5 +296,3 @@ NOTE: Once at least one account is added, you can run | |||
| \`mbsync -a\` to begin downloading mail. | |||
| EOF | |||
| esac | |||
| rm -rf "$tmpdir" | |||