ls and delete work with accnums

This commit is contained in:
Luke Smith 2019-04-22 12:43:42 -04:00
parent ab8323f898
commit d48aafa1a1
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252

14
bin/mw
View File

@ -12,6 +12,9 @@ sslcert="/etc/ssl/certs/ca-certificates.crt"
mwconfig="$muttdir/mutt-wizard.muttrc" mwconfig="$muttdir/mutt-wizard.muttrc"
muttrc="$muttdir/muttrc" muttrc="$muttdir/muttrc"
getaccounts() { accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /g;s/\..*//" | sort -n)" ;}
list() { getaccounts && echo "$accounts" ;}
getprofiles() { \ getprofiles() { \
unset msmtp_header msmtp_profile mutt_profile mbsync_profile unset msmtp_header msmtp_profile mutt_profile mbsync_profile
printf "Creating profiles for \`%s\`..." "$title" printf "Creating profiles for \`%s\`..." "$title"
@ -148,7 +151,7 @@ EOF
read -r login read -r login
printf "\033[0m" printf "\033[0m"
[ -z "$login" ] && login="$fulladdr" [ -z "$login" ] && login="$fulladdr"
accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /g;s/\..*//" | sort -n)" getaccounts
for x in $(seq 1 9); do echo "$accounts" | grep "$x" || { export idnum="$x"; break ;}; done for x in $(seq 1 9); do echo "$accounts" | grep "$x" || { export idnum="$x"; break ;}; done
getpass getpass
getprofiles getprofiles
@ -214,18 +217,11 @@ confirm() { printf "Do you want to to %s? [y/N]\\n\t" "$@" && read -r input && !
printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "^y$\|^yes$" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "^y$\|^yes$" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1
return 0 ;} return 0 ;}
list() { numbered="$(find "$accdir" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | nl)"
echo "$numbered"
[ "$(echo "$numbered" | wc -l)" = 0 ] && printf "No configured accounts.\\n" && return 1
}
pick() { printf "Select an accounts to %s:\\n" "$1" pick() { printf "Select an accounts to %s:\\n" "$1"
list list
printf "\033[36m\t"
read -r input read -r input
printf "\033[0m"
[ -z "$input" ] && return 1 [ -z "$input" ] && return 1
title="$(echo "$numbered" | grep "$input" | awk '{print $2}')" title="$(echo "$accounts" | grep "$input" | awk '{print $2}')"
[ -z "$title" ] && printf "Invalid response." && return 1 [ -z "$title" ] && printf "Invalid response." && return 1
return 0 ;} return 0 ;}