diff --git a/README.md b/README.md index 404bc23..7b411a4 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,8 @@ mutt-wizard is free/libre software, licensed under the GPLv3. You can edit these freely if you want to tinker with settings specific to an account. - In `/usr/share/mutt-wizard` are several global config files, including `mutt-wizard`'s default settings. You can overwride this in your `muttrc` if you wish. + To avoid insertion of the line sourcing the default settings, + have a commented `# source /usr/share/mutt-wizard/mutt-wizard.muttrc` in your muttrc. ## Watch out for these things: diff --git a/bin/mw b/bin/mw index 0024c3c..25f9541 100755 --- a/bin/mw +++ b/bin/mw @@ -196,20 +196,22 @@ EOF getprofiles mkdir -p "$mwmuttdir" "$mwaccdir" "$mwcachedir/$mwaccount/bodies" "$mwconfigdir/msmtp" getaccounts - for x in $(seq 1 9); do echo "$accounts" | grep "$x" >/dev/null 2>&1 || { export idnum="$x"; break ;}; done + for x in $(seq 1 9); do echo "$accounts" | grep "$x": >/dev/null 2>&1 || { export idnum="$x"; break ;}; done [ ! -f "$mwmsmtprc" ] && echo "$msmtp_header" > "$mwmsmtprc" echo "$msmtp_profile" >> "$mwmsmtprc" case "$mwservice" in protonmail.ch|protonmail.com|pm.me) protonfinger || return 1 ;; esac - echo "$mutt_profile" > "$mwaccdir/$idnum-$mwaccount.muttrc" mkdir -p ${mwmbsyncrc%/*} echo "$mbsync_profile" >> "$mwmbsyncrc" + echo "$mutt_profile" > "$mwaccdir/$idnum-$mwaccount.muttrc" [ ! -f "$mwmuttrc" ] && echo "# vim: filetype=neomuttrc" > "$mwmuttrc" && echo "muttrc created." - ! grep "^source.*mutt-wizard.muttrc" "$mwmuttrc" >/dev/null && echo "source $mwconfig # mw-autogenerated" >> "$mwmuttrc" - ! grep "^source.*.muttrc" "$mwmuttrc" | grep -v "$mwconfig" >/dev/null && echo "source $mwaccdir/$idnum-$mwaccount.muttrc # mw-autogenerated" >> "$mwmuttrc" - echo "macro index,pager i$idnum 'source $mwaccdir/$idnum-$mwaccount.muttrc!;' \"switch to $mwaddr\" # mw-autogenerated" >> "$mwmuttrc" - [ "$mwtype" = "offline" ] && echo "macro index gM 'mailsync -Va' \"sync all mail\" # mw-autogenerated" >> "$mwmuttrc" + ! grep "source.*mutt-wizard.muttrc" "$mwmuttrc" >/dev/null && echo "source $mwconfig # mw-autogenerated" >> "$mwmuttrc" + ! grep "^source.*$idnum-$mwaccount.muttrc" "$mwmuttrc" >/dev/null && echo "source $mwaccdir/$idnum-$mwaccount.muttrc # mw-autogenerated" >> "$mwmuttrc" + ! grep "^macro .* i$idnum .*" "$mwmuttrc" >/dev/null && echo "macro index,pager i$idnum 'source $mwaccdir/$idnum-$mwaccount.muttrc!;' \"switch to $mwaddr\" # mw-autogenerated" >> "$mwmuttrc" + if [ "$mwtype" = "offline" ]; then + ! grep "^macro .* gM .*" "$mwmuttrc" >/dev/null && echo "macro index gM 'mailsync -Va' \"sync all mail\" # mw-autogenerated" >> "$mwmuttrc" + fi return 0 } @@ -257,8 +259,8 @@ finalize() { trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g') sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$mwaccdir/$idnum-$mwaccount.muttrc" { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$mwaccdir/$idnum-$mwaccount.muttrc" - echo "mailboxes =${mwaccount//[.@]/_} ===================== $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" - >> "$mwaccdir/$idnum-$mwaccount.muttrc" + mwaccount_="${mwaccount//[.@]/_}" + echo "mailboxes =${mwaccount_%_*} ===================== $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$mwaccdir/$idnum-$mwaccount.muttrc" printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" sed -i "/# mw-autogenerated/d" "$mwaccdir/$idnum-$mwaccount.muttrc" echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index 9189131..591ac15 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -78,6 +78,7 @@ set sidebar_format = '%B%?F? [%F]?%* %?N?%N/? %?S?%S?' bind index,pager \Ck sidebar-prev bind index,pager \Cj sidebar-next bind index,pager \Co sidebar-open +bind index,pager \Cl sidebar-open bind index,pager \Cp sidebar-prev-new bind index,pager \Cn sidebar-next-new bind index,pager B sidebar-toggle-visible diff --git a/test/dotests b/test/dotests index 64b5f11..a2bd649 100755 --- a/test/dotests +++ b/test/dotests @@ -28,14 +28,14 @@ export mwpass=mutt-wizard-$mwaddr echo "= manual test 1 =" mwtype=online mw add -echo "=> In another window, enter mutt and verify that mails are shown" +echo "=> In another window, start mutt and verify that mails are shown" mw purge rm -rf $mwmaildir/$mwaddr echo "= manual test 2 =" mwtype=offline mw add mailsync -echo "=> In another window, enter mutt and verify that mails are shown" +echo "=> In another window, start mutt and verify that mails are shown" echo "=> In mutt press gm and gM, to start mailsync" mw purge rm -rf $mwmaildir/$mwaddr