You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
984 B

  1. #!/bin/sh
  2. muttdir="$HOME/.config/mutt/"
  3. # This script will remove an account from ~/.offlineimaprc and the
  4. # designated location in ~/.config/mutt/accounts.
  5. # Feed the script the title of the account.
  6. cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered
  7. removeAccount() { sed -ie "
  8. /Account $1]/,/Account/{//!d}
  9. /Account $1]/d
  10. s/ $1\(,\|$\)//g
  11. s/=$1\(,\|$\)/=/g
  12. s/,$//g
  13. " ~/.offlineimaprc
  14. rm "$muttdir"accounts/$1.muttrc
  15. echo $1 deleted. ;}
  16. #/tmp/numbered
  17. accounts=()
  18. while read n s ; do
  19. accounts+=($n "$s" off)
  20. done < /tmp/numbered
  21. choices=$(dialog --separate-output --checklist "Choose an email account to remove." 22 76 16 "${accounts[@]}" 2>&1 >/dev/tty)
  22. clear
  23. if [ -z "$choices" ];
  24. then
  25. echo no selection
  26. else
  27. todelet=$(IFS="|"; keys="${choices[*]}"; keys="${keys//|/\\|}"; grep -w "${keys}" /tmp/numbered | awk '{print $2}')
  28. for i in $todelet; do removeAccount $i; done
  29. fi