diff options
author | Luke <luke@lukesmith.xyz> | 2018-02-10 10:12:10 -0700 |
---|---|---|
committer | Luke <luke@lukesmith.xyz> | 2018-02-10 10:12:10 -0700 |
commit | 7a8ded1b6c6f9a018785e5cda90c7508ad50d8b3 (patch) | |
tree | 2b931faaf370a366b86101ea0ebd6691a62802e6 /removeaccount.sh | |
parent | becd87feaec9a42f83e1eadd6c92b103721efe18 (diff) |
remove script now visual
Diffstat (limited to 'removeaccount.sh')
-rwxr-xr-x | removeaccount.sh | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/removeaccount.sh b/removeaccount.sh index 43bf3b9..cfae388 100755 --- a/removeaccount.sh +++ b/removeaccount.sh @@ -6,15 +6,35 @@ muttdir="$HOME/.config/mutt/" # Feed the script the title of the account. -title=$1 +cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered removeAccount() { sed -ie " - /Account $title]/,/Account/{//!d} - /Account $title]/d - s/ $title\(,\|$\)//g - s/=$title\(,\|$\)/=/g + /Account $1]/,/Account/{//!d} + /Account $1]/d + s/ $1\(,\|$\)//g + s/=$1\(,\|$\)/=/g s/,$//g " ~/.offlineimaprc - rm "$muttdir"accounts/$title.muttrc - echo $title deleted. ;} -#removeAccount $title + rm "$muttdir"accounts/$1.muttrc + echo $1 deleted. ;} + +#/tmp/numbered + +accounts=() +while read n s ; do + accounts+=($n "$s" off) +done < /tmp/numbered + +choices=$(dialog --separate-output --checklist "Choose an email account to remove." 22 76 16 "${accounts[@]}" 2>&1 >/dev/tty) +clear + +if [ -z "$choices" ]; + then + echo no selection + else + todelet=$(IFS="|"; keys="${choices[*]}"; keys="${keys//|/\\|}"; grep -w "${keys}" /tmp/numbered | awk '{print $2}') + for i in $todelet; do removeAccount $i; done +fi + + + |