From fce9df14fdd459052efce32476e3bdad70e8b8c1 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 22 Apr 2019 13:12:08 -0400 Subject: [PATCH] idnum fixes --- bin/mw | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/mw b/bin/mw index 595f37b..fcfbb09 100755 --- a/bin/mw +++ b/bin/mw @@ -160,7 +160,7 @@ EOF echo "$msmtp_profile" >> "$HOME/.config/msmtp/config" echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc" echo "$mbsync_profile" >> "$mbsyncrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$title.muttrc # mw-autogenerated" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc # mw-autogenerated" >> "$muttrc" echo "macro index,pager i$idnum 'source $accdir/$idnum-$title.muttrc!;' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc" } @@ -170,7 +170,7 @@ getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1 formatShortcut() { \ while read -r data; do { echo "macro index,pager g$1 \"$data\" \"go to $2\" # mw-autogenerated" echo "macro index,pager M$1 \"$data\" \"move mail to $2\" # mw-autogenerated" - echo "macro index,pager C$1 \"$data\" \"copy mail to $2\" # mw-autogenerated"; } >> "$accdir/$3.muttrc" + echo "macro index,pager C$1 \"$data\" \"copy mail to $2\" # mw-autogenerated"; } >> "$accdir/$idnum-$title.muttrc" done ;} tryconnect() { mkdir -p "$maildir/$title" @@ -198,18 +198,18 @@ finalize() { \ 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') - sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$title.muttrc" - { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$title.muttrc" - echo mailboxes "$oneline" >> "$accdir/$title.muttrc" + 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/$title.muttrc" - grep -i -m 1 inbox "$tmpdir/title_boxes" | formatShortcut i inbox "$title" - grep -i -m 1 sent "$tmpdir/title_boxes" | formatShortcut s sent "$title" - grep -i -m 1 draft "$tmpdir/title_boxes" | formatShortcut d drafts "$title" - grep -i -m 1 trash "$tmpdir/title_boxes" | formatShortcut t trash "$title" - grep -i -m 1 spam "$tmpdir/title_boxes" | formatShortcut S spam "$title" - grep -i -m 1 junk "$tmpdir/title_boxes" | formatShortcut j junk "$title" - grep -i -m 1 archive "$tmpdir/title_boxes" | formatShortcut a archive "$title" + 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 [ "$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" } @@ -227,7 +227,7 @@ pick() { printf "Select an accounts to %s:\\n" "$1" delete() { sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" rm -rf "${accdir:?}/${title:?}" "$accdir/[1-9]-$title.muttrc" - sed -i "/$title.muttrc/d" "$muttrc" + sed -i "/[0-9]-$title.muttrc/d" "$muttrc" sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config" }