mutt-wizard

fork of Luke Smiths mutt-wizard
git clone git://git.jakekoroman.com/mutt-wizard
Log | Files | Refs | README | LICENSE

commit ab8323f898a0234a969fb20d9c2ee0818068fe73
parent d439fbd646061af8123d65f6d15ad0147e9e8029
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Mon, 22 Apr 2019 12:39:20 -0400

muttrcs keep account number

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

diff --git a/bin/mw b/bin/mw @@ -148,19 +148,17 @@ EOF read -r login printf "\033[0m" [ -z "$login" ] && login="$fulladdr" - tmpdir="$(mktemp -d)" - grep "i[0-9]" "$muttrc" 2>/dev/null | awk '{print $3}' | sed -e 's/i//g' > "$tmpdir/mutt_used" - seq 1 9 > "$tmpdir/mutt_all" - idnum=$(diff "$tmpdir/mutt_all" "$tmpdir/mutt_used" | sed -n 2p | awk '{print $2}') + accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /g;s/\..*//" | sort -n)" + for x in $(seq 1 9); do echo "$accounts" | grep "$x" || { export idnum="$x"; break ;}; done getpass getprofiles mkdir -p "$accdir/$title/cache/bodies" "$HOME/.config/msmtp" [ ! -f "$HOME/.config/msmtp/config" ] && echo "$msmtp_header" > "$HOME/.config/msmtp/config" echo "$msmtp_profile" >> "$HOME/.config/msmtp/config" - echo "$mutt_profile" > "$accdir/$title.muttrc" + 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" - echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc" + echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc" } getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1 @@ -185,6 +183,7 @@ 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}')" @@ -231,7 +230,7 @@ pick() { printf "Select an accounts to %s:\\n" "$1" return 0 ;} delete() { sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" - rm -rf "${accdir:?}/${title:?}" "$accdir/$title.muttrc" + rm -rf "${accdir:?}/${title:?}" "$accdir/[1-9]-$title.muttrc" sed -i "/$title.muttrc/d" "$muttrc" sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config" }