mutt-wizard

A wizard that autocreates an offline email setup for (neo)mutt with isync/mbsync
Log | Files | Refs | README | LICENSE

commit e81e2c450d9627f1e7259ac23ff550adc1e83b33
parent b53babb00c545b4f1f7fddb1ce515b5f0a76f7b5
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Fri, 26 Apr 2019 11:36:14 -0400

sed portable?

Diffstat:
Mbin/mw | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/bin/mw b/bin/mw @@ -182,7 +182,7 @@ formatShortcut() { \ tryconnect() { mkdir -p "$maildir/$title" if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ "$accounttype" = "online" ] && sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" + [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsync"bu printf "\033[32mMailboxes detected.\033[0m\\n" echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$title/{}" return 0 @@ -199,11 +199,11 @@ finalize() { \ 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" + sed -ibu "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc" echo "mailboxes =$title ===================== $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc" printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" - sed -i "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" + sed -ibu "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox echo "$boxes" | grep -i sent | head -n 1 | formatShortcut s sent echo "$boxes" | grep -i draft | head -n 1 | formatShortcut d drafts @@ -227,10 +227,10 @@ pick() { printf "Select an accounts to %s:\\n" "$1" [ -z "$title" ] && printf "Invalid response." && return 1 return 0 ;} -delete() { sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" +delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu rm -rf "${cachedir:?}/${title:?}" "$accdir/"[1-9]"-$title.muttrc" - sed -i "/[0-9]-$title.muttrc/d" "$muttrc" - sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config" + sed -ibu "/[0-9]-$title.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu + sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config"; rm -f "$HOME/.config/msmtp/configbu" } choosecron() { ! pgrep -x cron\|crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 @@ -266,7 +266,7 @@ asktype() { while : ; do purge() { confirm "delete all account data" || exit rm -rf "$mbsyncrc" "$accdir" "$HOME/.config/msmtp" "$cachedir" echo "All configs and account settings have been purged." - sed -i "/\# mw-autogenerated/d" "$muttrc" + sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu } notmuchauto() { \