shellchecked
This commit is contained in:
parent
71c80b72d5
commit
cd13ef20f0
@ -16,7 +16,7 @@ if [ "$(uname)" = "Darwin" ]
|
|||||||
then
|
then
|
||||||
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
|
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
|
||||||
else
|
else
|
||||||
notify() { mpv --really-quiet ~/.config/mutt/bin/notify.opus & pgrep -x dunst && notify-send -i ~/.config/mutt/bin/email.gif "$2 new mail(s) in \`$1\` account." ;}
|
notify() { mpv --really-quiet "$HOME/.config/mutt/bin/notify.opus" & pgrep -x dunst && notify-send -i "$HOME/.config/mutt/bin/email.gif" "$2 new mail(s) in \`$1\` account." ;}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " 🔃" > /tmp/imapsyncicon
|
echo " 🔃" > /tmp/imapsyncicon
|
||||||
|
29
mw
29
mw
@ -18,7 +18,7 @@ case "$(uname)" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
getprofiles() { \
|
getprofiles() { \
|
||||||
printf "Creating profiles for \`$title\`..."
|
printf "Creating profiles for \`%s\`..." "$title"
|
||||||
offlineimap_header="[general]
|
offlineimap_header="[general]
|
||||||
accounts =
|
accounts =
|
||||||
starttls = yes
|
starttls = yes
|
||||||
@ -111,14 +111,14 @@ addaccount() { \
|
|||||||
read -r sport
|
read -r sport
|
||||||
printf "\\nGreat! If you want to be helpful, copy the line below and you can add it to the \`domains.csv\` file on Github.\\nThis will make things easier for others who use your email provider.\\n\\n%s,%s,%s,%s,%s\\n\\nAlthough be sure to test to see if these settings work first! ;-)\\n" "$domain" "$imap" "$iport" "$smtp" "$sport"
|
printf "\\nGreat! If you want to be helpful, copy the line below and you can add it to the \`domains.csv\` file on Github.\\nThis will make things easier for others who use your email provider.\\n\\n%s,%s,%s,%s,%s\\n\\nAlthough be sure to test to see if these settings work first! ;-)\\n" "$domain" "$imap" "$iport" "$smtp" "$sport"
|
||||||
else
|
else
|
||||||
IFS=, read service imap iport smtp sport <<EOF
|
IFS=, read -r service imap iport smtp sport <<EOF
|
||||||
$serverinfo
|
$serverinfo
|
||||||
EOF
|
EOF
|
||||||
printf "\\n\033[3;33mCongrats!\033[0m Server info has automatically be found, so you won't have to look anything up!\\n\t\033[1mIMAP server\033[0m: %s\\n\t\033[1mIMAP port\033[0m: %s\\n\t\033[1mSMTP server\033[0m: %s\\n\t\033[1mSMTP port\033[0m: %s\\nThis data will be used by the wizard.\\n" "$imap" "$iport" "$smtp" "$sport"
|
printf "\\n\033[3;33mCongrats!\033[0m Server info has automatically be found, so you won't have to look anything up!\\n\t\033[1mIMAP server\033[0m: %s\\n\t\033[1mIMAP port\033[0m: %s\\n\t\033[1mSMTP server\033[0m: %s\\n\t\033[1mSMTP port\033[0m: %s\\nThis data will be used by the wizard.\\n" "$imap" "$iport" "$smtp" "$sport"
|
||||||
fi
|
fi
|
||||||
printf "\\nPress enter to continue.\\n"
|
printf "\\nPress enter to continue.\\n"
|
||||||
stty -echo
|
stty -echo
|
||||||
read wait
|
read -r
|
||||||
stty echo
|
stty echo
|
||||||
printf "Enter the \033[35mfull name\033[0m you want to be identified by on this account.\\n\tReal name: "
|
printf "Enter the \033[35mfull name\033[0m you want to be identified by on this account.\\n\tReal name: "
|
||||||
read -r realname
|
read -r realname
|
||||||
@ -142,7 +142,7 @@ EOF
|
|||||||
idnum=$(diff "$tmpdir/mutt_all" "$tmpdir/mutt_used" | sed -n 2p | awk '{print $2}')
|
idnum=$(diff "$tmpdir/mutt_all" "$tmpdir/mutt_used" | sed -n 2p | awk '{print $2}')
|
||||||
getpass "$title"
|
getpass "$title"
|
||||||
getprofiles
|
getprofiles
|
||||||
mkdir -p "$accdir"
|
mkdir -p "$accdir/$title/cache/bodies"
|
||||||
mkdir -p "$HOME/.config/offlineimap/" "$HOME/.config/msmtp"
|
mkdir -p "$HOME/.config/offlineimap/" "$HOME/.config/msmtp"
|
||||||
[ ! -f "$HOME/.config/offlineimap/config" ] && echo "$offlineimap_header" > "$HOME/.config/offlineimap/config"
|
[ ! -f "$HOME/.config/offlineimap/config" ] && echo "$offlineimap_header" > "$HOME/.config/offlineimap/config"
|
||||||
[ ! -f "$HOME/.config/msmtp/config" ] && echo "$msmtp_header" > "$HOME/.config/msmtp/config"
|
[ ! -f "$HOME/.config/msmtp/config" ] && echo "$msmtp_header" > "$HOME/.config/msmtp/config"
|
||||||
@ -161,7 +161,7 @@ getpass() { \
|
|||||||
read -r password
|
read -r password
|
||||||
stty echo
|
stty echo
|
||||||
echo "$password" > "$tmpdir/$1"
|
echo "$password" > "$tmpdir/$1"
|
||||||
printf "Encrypting your password with %s..."
|
printf "Encrypting your password with %s..." "$GPG"
|
||||||
"$GPG" -r "$gpgemail" --encrypt "$tmpdir/$1"
|
"$GPG" -r "$gpgemail" --encrypt "$tmpdir/$1"
|
||||||
printf "DONE\\nShredding all memory of your password for safety's sake..."
|
printf "DONE\\nShredding all memory of your password for safety's sake..."
|
||||||
unset password
|
unset password
|
||||||
@ -188,7 +188,7 @@ askgpg() { \
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatShortcut() { \
|
formatShortcut() { \
|
||||||
while read data; do { echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\" # autogenerated"
|
while read -r data; do { echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\" # autogenerated"
|
||||||
echo "macro index,pager M$1 \"<save-message>$data<enter>\" \"Move mail to $2.\" # autogenerated"
|
echo "macro index,pager M$1 \"<save-message>$data<enter>\" \"Move mail to $2.\" # autogenerated"
|
||||||
echo "macro index,pager C$1 \"<copy-message>$data<enter>\" \"Copy mail to $2.\" # autogenerated"; } >> "$muttdir/accounts/$3.muttrc"
|
echo "macro index,pager C$1 \"<copy-message>$data<enter>\" \"Copy mail to $2.\" # autogenerated"; } >> "$muttdir/accounts/$3.muttrc"
|
||||||
done ;}
|
done ;}
|
||||||
@ -203,14 +203,14 @@ gen_delim() { \
|
|||||||
|
|
||||||
trysync() { \
|
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" && return 1
|
! 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" && return 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."
|
printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-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
|
stty -echo
|
||||||
read wait
|
read -r
|
||||||
stty echo
|
stty echo
|
||||||
mkdir -p "$maildir"
|
|
||||||
(sleep 15; killall offlineimap; killall offlineimap; killall offlineimap)>/dev/null 2>&1 &
|
(sleep 15; killall offlineimap; killall offlineimap; killall offlineimap)>/dev/null 2>&1 &
|
||||||
|
mkdir -p "$maildir"
|
||||||
offlineimap -qoa "$title"
|
offlineimap -qoa "$title"
|
||||||
if ls -d "$maildir/$1/"* >/dev/null 2>&1; then
|
if ls -d "$maildir/$title/"* >/dev/null 2>&1; then
|
||||||
printf "\033[32mSync successful.\033[0m\\n"; return
|
printf "\033[32mSync successful.\033[0m\\n"; return
|
||||||
else
|
else
|
||||||
printf "\033[31m\033[31mSync not successful.\033[0m Try running offlineimap manually after double-checking your password and server settings.\\nThen select to finalize the account.\\n"; return 1
|
printf "\033[31m\033[31mSync not successful.\033[0m Try running offlineimap manually after double-checking your password and server settings.\\nThen select to finalize the account.\\n"; return 1
|
||||||
@ -218,7 +218,7 @@ trysync() { \
|
|||||||
}
|
}
|
||||||
|
|
||||||
finalize() { \
|
finalize() { \
|
||||||
boxes="$(ls -d "$maildir/$title/"* 2>/dev/null | sed "s/.*\///;s/^/=/")"
|
boxes="$(du -a "$maildir/$title/"* -d 0 | sed "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" "$title" && return
|
[ -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" "$title" && return
|
||||||
echo "$boxes" > "$tmpdir/title_boxes"
|
echo "$boxes" > "$tmpdir/title_boxes"
|
||||||
printf "Setting up the mutt sidebar...\\n"
|
printf "Setting up the mutt sidebar...\\n"
|
||||||
@ -256,9 +256,10 @@ pick() { \
|
|||||||
printf "Select (an) account(s) to %s.\\n" "$1"
|
printf "Select (an) account(s) to %s.\\n" "$1"
|
||||||
echo "$numbered"
|
echo "$numbered"
|
||||||
read -r input
|
read -r input
|
||||||
|
[ -z "$input" ] && return 1
|
||||||
title="$(echo "$numbered" | grep "$input" | awk '{print $2}')"
|
title="$(echo "$numbered" | grep "$input" | awk '{print $2}')"
|
||||||
[ -z "$title" ] && printf "Invalid response." && return 1
|
[ -z "$title" ] && printf "Invalid response." && return 1
|
||||||
[ ! -z "$2" ] && printf "Are you sure you want to %s the \`%s\` account?" "$1" "$title" && read -r input && echo "$input" | grep -i "y\(es\)*" >/dev/null
|
[ -n "$2" ] && printf "Are you sure you want to %s the \`%s\` account?" "$1" "$title" && read -r input && echo "$input" | grep -i "y\(es\)*" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() { sed -i "
|
delete() { sed -i "
|
||||||
@ -268,7 +269,7 @@ delete() { sed -i "
|
|||||||
s/=$1\(,\|$\)/=/g
|
s/=$1\(,\|$\)/=/g
|
||||||
s/,$//g
|
s/,$//g
|
||||||
" "$HOME/.config/offlineimap/config"
|
" "$HOME/.config/offlineimap/config"
|
||||||
rm -rf "$accdir/$1" "$creddir/$1.gpg" "$accdir/$1.muttrc"
|
rm -rf "${accdir:?}/${1:?}" "$creddir/$1.gpg" "$accdir/$1.muttrc"
|
||||||
sed -i "/$1.muttrc/d" "$muttdir/personal.muttrc"
|
sed -i "/$1.muttrc/d" "$muttdir/personal.muttrc"
|
||||||
# Delete from the line matching the account name, until the next account or empty line
|
# Delete from the line matching the account name, until the next account or empty line
|
||||||
sed -i "/account $1/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config";}
|
sed -i "/account $1/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config";}
|
||||||
@ -288,7 +289,7 @@ Input a number to continue or press ctrl-c.\\n"
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1) addaccount ;;
|
1) addaccount ;;
|
||||||
2) pick finalize && finalize "$title" ;;
|
2) pick finalize && finalize "$title" ;;
|
||||||
2) break ;;
|
3) break ;;
|
||||||
4) pick delete yes && delete "$title" ;;
|
4) pick delete yes && delete "$title" ;;
|
||||||
5) askgpg ;;
|
5) askgpg ;;
|
||||||
6) printf "Are you \033[31;1mreally\033[0m sure you want to delete all email accounts?\\n" && read -r input && echo "$input" | grep -i "y\(es\)*" >/dev/null && wipe && printf "Account data purged." ;;
|
6) printf "Are you \033[31;1mreally\033[0m sure you want to delete all email accounts?\\n" && read -r input && echo "$input" | grep -i "y\(es\)*" >/dev/null && wipe && printf "Account data purged." ;;
|
||||||
|
Loading…
Reference in New Issue
Block a user