|
|
@@ -34,7 +34,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" |
|
|
|
echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)" |
|
|
|
exit 1 ;} ;} |
|
|
|
|
|
|
|
getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} |
|
|
|
getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "\S*.muttrc" | sed "s|.*/\([0-9]-\)*||;s/\.muttrc$//" | nl)" ;} |
|
|
|
|
|
|
|
list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} |
|
|
|
|
|
|
@@ -104,12 +104,12 @@ set hostname = \"$hostname\" |
|
|
|
source $muttshare/unbind.muttrc |
|
|
|
$extra |
|
|
|
$synccmd |
|
|
|
" > "$accdir/$idnum-$fulladdr.muttrc" |
|
|
|
" > "$accdir/$fulladdr.muttrc" |
|
|
|
|
|
|
|
[ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" |
|
|
|
! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >> "$muttrc" |
|
|
|
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" |
|
|
|
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\"" >> "$muttrc" |
|
|
|
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$fulladdr.muttrc" >> "$muttrc" |
|
|
|
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\"" >> "$muttrc" |
|
|
|
} |
|
|
|
|
|
|
|
getprofiles() { \ |
|
|
@@ -156,18 +156,18 @@ delete() { if [ -z "${fulladdr+x}" ]; then |
|
|
|
echo "Select the account you would like to delete (by number):" |
|
|
|
list || exit 1 |
|
|
|
read -r input |
|
|
|
match="^$input:" |
|
|
|
match="^\s*$input\s\+" |
|
|
|
else |
|
|
|
match=" $fulladdr$" |
|
|
|
match="\s\+$fulladdr$" |
|
|
|
getaccounts |
|
|
|
fi |
|
|
|
|
|
|
|
fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')" |
|
|
|
fulladdr="$(echo "$accounts" | grep "$match" | grep -o "\S*@\S*")" |
|
|
|
|
|
|
|
[ -z "$fulladdr" ] && echo "$fulladdr is not a valid account name." && return 1 |
|
|
|
|
|
|
|
sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu |
|
|
|
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" |
|
|
|
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/$fulladdr.muttrc" "$accdir/"[0-9]-"$fulladdr.muttrc" |
|
|
|
sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu |
|
|
|
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu |
|
|
|
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu |
|
|
@@ -224,11 +224,15 @@ getboxes() { if [ -n "${force+x}" ] ; then |
|
|
|
else |
|
|
|
info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" |
|
|
|
[ -z "$info" ] && echo "Log-on not successful." && return 1 |
|
|
|
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' |
|
|
|
')" |
|
|
|
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" |
|
|
|
fi |
|
|
|
[ "$type" = "pop" ] && mailboxes="INBOX" |
|
|
|
getaccounts; for x in 1 2 3 4 5 6 7 8 9; do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done |
|
|
|
getaccounts |
|
|
|
usednums="$(grep -o "^macro.* i[0-9]\+ " "$muttrc" | grep -o "[0-9]" | sort -u)" |
|
|
|
for x in 1 2 3 4 5 6 7 8 9; do |
|
|
|
echo "$usednums" | grep -q "$x" || |
|
|
|
{ export idnum="$x"; break ;} |
|
|
|
done |
|
|
|
toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" |
|
|
|
IFS=' |
|
|
|
' |
|
|
@@ -246,7 +250,7 @@ getboxes() { if [ -n "${force+x}" ] ; then |
|
|
|
unset IFS |
|
|
|
} |
|
|
|
|
|
|
|
finalize() { echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" |
|
|
|
finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc" |
|
|
|
[ "$type" != "online" ] && echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" |
|
|
|
echo "$fulladdr (account #$idnum) added successfully." |
|
|
|
command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" |
|
|
|