trysync added and narration
This commit is contained in:
parent
ffb98868a4
commit
8722d9304e
33
mw
33
mw
@ -89,8 +89,6 @@ unmailboxes *
|
||||
"
|
||||
}
|
||||
|
||||
userexit() { clear; exit ;}
|
||||
|
||||
addaccount() { \
|
||||
printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/offlineIMAP\\n\\nEmail: "
|
||||
read -r fulladdr
|
||||
@ -142,7 +140,7 @@ EOF
|
||||
grep "i[0-9]" "$muttdir/personal.muttrc" | awk '{print $3}' | sed -e 's/i//g' > "$tmpdir/mutt_used"
|
||||
printf "1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9" > "$tmpdir/mutt_all_possible"
|
||||
idnum=$(diff "$tmpdir/mutt_all_possible" "$tmpdir/mutt_used" | sed -n 2p | awk '{print $2}')
|
||||
getpass "$title" || userexit
|
||||
getpass "$title"
|
||||
getprofiles
|
||||
mkdir -p "$HOME/.config/offlineimap/" "$HOME/.config/msmtp"
|
||||
[ ! -f "$HOME/.config/offlineimap/config" ] && echo "$offlineimap_header" > "$HOME/.config/offlineimap/config"
|
||||
@ -196,14 +194,35 @@ gen_delim() { \
|
||||
done
|
||||
echo $delim ;}
|
||||
|
||||
trysync() { \
|
||||
! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning offlineimap manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" && exit 1
|
||||
printf "mutt-wizard will run offlineimap briefly to (1) ensure that login details are functional and (2) allow offlineimap to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run offlineimap manually to finish the mail sync later.\\nPress enter to continue.\\n."
|
||||
stty -echo
|
||||
read wait
|
||||
stty echo
|
||||
(sleep 15; killall offlineimap; killall offlineimap; killall offlineimap) &
|
||||
offlineimap -qoa "$title"
|
||||
exit 0
|
||||
}
|
||||
|
||||
detectMailboxes() { \
|
||||
ls -d "$maildir/$1/"* | sed "s/.*\///;s/^/=/" > "$tmpdir/$1_boxes"
|
||||
boxes="$(ls -d "$maildir/$1/"* 2>/dev/null | sed "s/.*\///;s/^/=/")"
|
||||
[ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that offlineimap has not been successfully run.\\nRun offlineimap, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$1" && exit
|
||||
echo "$boxes" > "$tmpdir/$1_boxes"
|
||||
printf "Setting up the mutt sidebar...\\n"
|
||||
sidebar_width="$(sed -n -e '/^set sidebar_width/p' "$muttdir/muttrc" | awk -F'=' '{print $2}')"
|
||||
delim="$(gen_delim "$sidebar_width")"
|
||||
printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n"
|
||||
oneline="$(sed -e "s/^\|$/\"/g" "$tmpdir/$1_boxes" | tr "\n" " ")"
|
||||
oneline="=$1 $delim $oneline"
|
||||
spoolfile=$(grep -i "$tmpdir/$1_boxes" -e inbox | sed -e 's/=/+/g' | sed 1q)
|
||||
record=$(grep -i "$tmpdir/$1_boxes" -e sent | sed -e 's/=/+/g' | sed 1q)
|
||||
postponed=$(grep -i "$tmpdir/$1_boxes" -e draft | sed -e 's/=/+/g' | sed 1q)
|
||||
trash=$(grep -i "$tmpdir/$1_boxes" -e trash | sed -e 's/=/+/g' | sed 1q)
|
||||
{ echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$muttdir/accounts/$1.muttrc"
|
||||
sed -i "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$muttdir/accounts/$1.muttrc"
|
||||
echo mailboxes "$oneline" >> "$muttdir/accounts/$1.muttrc"
|
||||
printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n"
|
||||
sed -i "/# autogenerated/d" "$muttdir/accounts/$1.muttrc"
|
||||
grep -i "$tmpdir/$1_boxes" -e inbox | sed 1q | formatShortcut i inbox "$1"
|
||||
grep -i "$tmpdir/$1_boxes" -e sent | sed 1q | formatShortcut s sent "$1"
|
||||
@ -212,11 +231,7 @@ detectMailboxes() { \
|
||||
grep -i "$tmpdir/$1_boxes" -e spam | sed 1q | formatShortcut S spam "$1"
|
||||
grep -i "$tmpdir/$1_boxes" -e junk | sed 1q | formatShortcut j junk "$1"
|
||||
grep -i "$tmpdir/$1_boxes" -e archive | sed 1q | formatShortcut a archive "$1"
|
||||
spoolfile=$(grep -i "$tmpdir/$1_boxes" -e inbox | sed -e 's/=/+/g' | sed 1q)
|
||||
record=$(grep -i "$tmpdir/$1_boxes" -e sent | sed -e 's/=/+/g' | sed 1q)
|
||||
postponed=$(grep -i "$tmpdir/$1_boxes" -e draft | sed -e 's/=/+/g' | sed 1q)
|
||||
trash=$(grep -i "$tmpdir/$1_boxes" -e trash | sed -e 's/=/+/g' | sed 1q)
|
||||
{ echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$muttdir/accounts/$1.muttrc"
|
||||
printf "All done.\\n"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user