您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

removeaccount.sh 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. rm "$muttdir"credentials/$1.gpg
  16. echo $1 deleted. ;}
  17. #/tmp/numbered
  18. accounts=()
  19. while read n s ; do
  20. accounts+=($n "$s" off)
  21. done < /tmp/numbered
  22. choices=$(dialog --separate-output --checklist "Choose an email account to remove." 22 76 16 "${accounts[@]}" 2>&1 >/dev/tty)
  23. clear
  24. if [ -z "$choices" ];
  25. then
  26. echo no selection
  27. else
  28. todelet=$(IFS="|"; keys="${choices[*]}"; keys="${keys//|/\\|}"; grep -w "${keys}" /tmp/numbered | awk '{print $2}')
  29. for i in $todelet; do removeAccount $i; done
  30. fi