Browse Source

mw -r to reorder account numbers

tags/v3.3
Luke Smith 2 years ago
parent
commit
85c5d01dcd
No known key found for this signature in database GPG Key ID: 4C50B54A911F6252
3 changed files with 27 additions and 1 deletions
  1. +1
    -0
      README.md
  2. +23
    -1
      bin/mw
  3. +3
    -0
      mw.1

+ 1
- 0
README.md View File

@@ -79,6 +79,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use
- `mw -D your@email.com` -- delete account settings without confirmation - `mw -D your@email.com` -- delete account settings without confirmation
- `mw -t 30` -- toggle automatic mailsync to every 30 minutes - `mw -t 30` -- toggle automatic mailsync to every 30 minutes
- `mw -T` -- toggle mailsync without specifying minutes (default is 10) - `mw -T` -- toggle mailsync without specifying minutes (default is 10)
- `mw -r` -- reorder account shortcut numbers
- `pass edit mw-your@email.com` -- revise an account's password - `pass edit mw-your@email.com` -- revise an account's password


### Options usable when adding an account ### Options usable when adding an account


+ 23
- 1
bin/mw View File

@@ -285,6 +285,7 @@ Main actions:
-Y Sync mail for all accounts -Y Sync mail for all accounts
-t number Toggle automatic mailsync every <number> minutes -t number Toggle automatic mailsync every <number> minutes
-T Toggle automatic mailsync -T Toggle automatic mailsync
-r Reorder account numbers


Options allowed with -a: Options allowed with -a:
-u Account login name if not full address -u Account login name if not full address
@@ -307,8 +308,28 @@ To change an account's password, run \`pass edit your@email.com\`.
EOF EOF
} }


while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
reorder(){
tempfile="$(mktemp -u)"
trap 'rm -f $tempfile' HUP INT QUIT TERM PWR EXIT
echo "# Carefully reorder these accounts with the desired numbers." > "$tempfile"
sed -n "
/ i[0-9] / s?\(.* i\|'<sync.*/\|\.muttrc.*\)??g p
" "$muttrc" > "$tempfile"
${EDITOR:-vim} "$tempfile" || exit 1
default="$(sort -n "$tempfile" | head -n 1)"
default="${default#* }"
sed -ibu "/.* i[0-9] .*.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu
awk -v a="$accdir" -v d="$default" ' BEGIN { print "source "a"/"d".muttrc" }
{
print "macro index,pager i"$1" '\''<sync-mailbox><enter-command>source "a"/"$2".muttrc<enter><change-folder>!<enter>;<check-stats>'\'' \"switch to "$2"\""
}
' "$tempfile" >> "$muttrc"

}

while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
l) setact list || exit 1 ;; l) setact list || exit 1 ;;
r) setact reorder || exit 1 ;;
d) setact delete || exit 1 ;; d) setact delete || exit 1 ;;
D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;;
y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; y) setact sync || exit 1 ; fulladdr="$OPTARG" ;;
@@ -347,5 +368,6 @@ case "$action" in
delete) delete ;; delete) delete ;;
sync) mailsync $fulladdr ;; sync) mailsync $fulladdr ;;
toggle) togglecron ;; toggle) togglecron ;;
reorder) reorder ;;
*) mwinfo; exit 1 ;; *) mwinfo; exit 1 ;;
esac esac

+ 3
- 0
mw.1 View File

@@ -41,6 +41,9 @@ toggle a cronjob that syncs your mail every 15 minutes (or any other number unde
.TP .TP
.B -T .B -T
toggle a cronjob without specifying minutes between sync toggle a cronjob without specifying minutes between sync
.TP
.B -r
reorder account shortcut numbers
.SH OPTIONS FOR ADDING ACCOUNTS .SH OPTIONS FOR ADDING ACCOUNTS
These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant. These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant.
.TP .TP


Loading…
Cancel
Save