Pārlūkot izejas kodu

some simplifications and soydevery removed

tags/v3.1
Luke Smith pirms 4 gadiem
vecāks
revīzija
a60f5e7fb6
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 4C50B54A911F6252
1 mainītis faili ar 27 papildinājumiem un 25 dzēšanām
  1. +27
    -25
      bin/mw

+ 27
- 25
bin/mw Parādīt failu

@@ -23,6 +23,7 @@ muttrc="$muttdir/muttrc"
msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config"
msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log"
ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail
MARKER="# mw-autogenerated"
alias mbsync='mbsync -c "$mbsyncrc"'

for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"
@@ -208,9 +209,9 @@ EOF
echo "$mbsync_profile" >> "$mbsyncrc"
notmuchauto
[ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created."
! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig # mw-autogenerated" >> "$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc # mw-autogenerated" >> "$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc"
! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig $MARKER" >> "$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc $MARKER" >> "$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" $MARKER" >> "$muttrc"
}

protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n"
@@ -221,11 +222,14 @@ protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n"
getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1
pass insert "mutt-wizard-$title" && break; done ;}

formatShortcut() { \
while read -r data; do { echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"go to $2\" # mw-autogenerated"
echo "macro index,pager M$1 \";<save-message>$data<enter>\" \"move mail to $2\" # mw-autogenerated"
echo "macro index,pager C$1 \";<copy-message>$data<enter>\" \"copy mail to $2\" # mw-autogenerated"; } >> "$accdir/$idnum-$title.muttrc"
done ;}
formatShortcut() { toappend="$toappend
macro index,pager g$1 \"<change-folder>=$3<enter>\" \"go to $2\" $MARKER
macro index,pager M$1 \";<save-message>=$3<enter>\" \"move mail to $2\" $MARKER
macro index,pager C$1 \";<copy-message>=$3<enter>\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$title.muttrc"
}

setBox() { toappend="$toappend
set $1 = \"+$2\" $MARKER" ;}

tryconnect() { mkdir -p "$maildir/$title"
if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then
@@ -239,25 +243,23 @@ tryconnect() { mkdir -p "$maildir/$title"
fi ;}

finalize() { \
boxes="$(find "$maildir/$title/" -mindepth 1 -type d | sed "s/\ /\\\ /g;s/^.*\//=/;/=\(cur\|new\|tmp\)$/d")"
boxes="$(find "$maildir/$title/" -mindepth 1 -type d | sed "s/\ /\\\ /g;s/^.*\///;/\(cur\|new\|tmp\)$/d")"
[ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && return
printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n"
spoolfile=$(echo "$boxes" | grep -i -m 1 inbox | sed 's/=/+/g')
record=$(echo "$boxes" | grep -i -m 1 sent | sed 's/=/+/g')
postponed=$(echo "$boxes" | grep -i -m 1 draft | sed 's/=/+/g')
trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g')
sed -ibu "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu"
{ echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc"
echo "mailboxes $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc"
sed -ibu "/$MARKER/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu"
toappend="mailboxes $(echo "$boxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )"
for x in $boxes; do
case $x in
*[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;;
*[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;;
*[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;;
*[Tt][Rr][Aa][Ss][Hh]*|*[Jj][Uu][Nn][Kk]*) formatShortcut t trash "$x"; setBox trash "$x" ;;
*[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;;
*[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;;
esac
done
printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n"
sed -ibu "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu"
echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox
echo "$boxes" | grep -i sent | head -n 1 | formatShortcut s sent
echo "$boxes" | grep -i draft | head -n 1 | formatShortcut d drafts
echo "$boxes" | grep -i trash | head -n 1 | formatShortcut t trash
echo "$boxes" | grep -i spam | head -n 1 | formatShortcut S spam
echo "$boxes" | grep -i junk | head -n 1 | formatShortcut j junk
echo "$boxes" | grep -i archive | head -n 1 | formatShortcut a archive
echo "$toappend" >> "$accdir/$idnum-$title.muttrc"
[ "$accounttype" = "offline" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title"
command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview"
return 0
@@ -293,7 +295,7 @@ asktype() { while : ; do
purge() { confirm "delete all account data" || exit
rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir"
echo "All configs and account settings have been purged."
sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu
sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu
}

syncwrapper() { mbsync "${1:--a}" &


Notiek ielāde…
Atcelt
Saglabāt