folders now fully autodetected
This commit is contained in:
parent
6f68023133
commit
534bb72ad5
@ -21,6 +21,3 @@ set ssl_force_tls = yes
|
||||
|
||||
bind index,pager g noop
|
||||
bind index gg first-entry
|
||||
macro index,pager gi "<change-folder>=$spoolfile<enter>" "Go to inbox"
|
||||
macro index,pager gs "<change-folder>=$record<enter>" "Go to sent"
|
||||
macro index,pager gd "<change-folder>=$postponed<enter>" "Go to drafts"
|
||||
|
@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
muttdir="$HOME/.config/mutt/"
|
||||
|
||||
find ~/.mail/$1 -maxdepth 1 -mindepth 1 -type d | sed -e "s/.*\///g;s/^/=/g" > /tmp/$1_boxes
|
||||
oneline=$(cat /tmp/$1_boxes | tr "\n" " ")
|
||||
sed -i "/^mailboxes/d" "$muttdir"accounts/$1.muttrc
|
||||
echo mailboxes $oneline >> "$muttdir"accounts/$1.muttrc
|
||||
|
||||
formatShortcut() { \
|
||||
while read data; do
|
||||
echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\"" >> "$muttdir"accounts/$3.muttrc
|
||||
done ;}
|
||||
|
||||
sed -i "/^macro index,pager g/d" "$muttdir"accounts/$1.muttrc
|
||||
|
||||
grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|junk\|archive" | sort -n | sed 1q | formatShortcut i inbox $1
|
||||
grep -i /tmp/$1_boxes -e sent | formatShortcut s sent $1
|
||||
grep -i /tmp/$1_boxes -e trash | formatShortcut t trash $1
|
||||
grep -i /tmp/$1_boxes -e spam | formatShortcut S spam $1
|
||||
grep -i /tmp/$1_boxes -e draft | formatShortcut d drafts $1
|
||||
grep -i /tmp/$1_boxes -e archive | formatShortcut a archive $1
|
||||
|
@ -2,24 +2,49 @@
|
||||
|
||||
muttdir="$HOME/.config/mutt/"
|
||||
|
||||
detectWarning() { \
|
||||
dialog --title "Mailbox detect requirement" --yesno "In order for the mailbox detection system to work, you must have
|
||||
|
||||
1) already have added the email account with this wizard, and
|
||||
2) already have run offlineimap at least once to synchronize your mail.
|
||||
|
||||
This detection system only works if you already have begun your first sync. If you have, press 'yes' to continue." 12 70 ;}
|
||||
|
||||
detectSuccess() { dialog --title "Mailbox detect complete." --msgbox "The script has now smartly detected your different mailboxes and has enabled them in the sidebar and given you keyboard shortcuts as below:
|
||||
|
||||
gi for move to the Inbox.
|
||||
gs for move to Sent Mail.
|
||||
gd for move to Drafts
|
||||
gS for move to Spam
|
||||
ga for move to the Archive.
|
||||
gj for move to Junk
|
||||
gt for move to Trash
|
||||
|
||||
These shortcuts will only work if your email system does have that particular folder (i.e. if your email system has a Junk folder, but not a Trash folder, 'gt' will not work, etc." 20 60 ;}
|
||||
|
||||
formatShortcut() { \
|
||||
while read data; do
|
||||
echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\"" >> "$muttdir"accounts/$3.muttrc
|
||||
done ;}
|
||||
|
||||
|
||||
detectMailboxes() { \
|
||||
find ~/.mail/$1 -maxdepth 1 -mindepth 1 -type d | sed -e "s/.*\///g;s/^/=/g" > /tmp/$1_boxes
|
||||
oneline=$(cat /tmp/$1_boxes | tr "\n" " ")
|
||||
sed -i "/^mailboxes/d" "$muttdir"accounts/$1.muttrc
|
||||
sed -i "/^mailboxes\|^set spoolfile\|^set record\|^set postponed/d" "$muttdir"accounts/$1.muttrc
|
||||
echo mailboxes $oneline >> "$muttdir"accounts/$1.muttrc
|
||||
sed -i "/^macro index,pager g/d" "$muttdir"accounts/$1.muttrc
|
||||
grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|junk\|archive" | sort -n | sed 1q | formatShortcut i inbox $1
|
||||
grep -i /tmp/$1_boxes -e sent | formatShortcut s sent $1
|
||||
grep -i /tmp/$1_boxes -e draft | formatShortcut d drafts $1
|
||||
grep -i /tmp/$1_boxes -e trash | formatShortcut t trash $1
|
||||
grep -i /tmp/$1_boxes -e spam | formatShortcut S spam $1
|
||||
grep -i /tmp/$1_boxes -e draft | formatShortcut d drafts $1
|
||||
grep -i /tmp/$1_boxes -e archive | formatShortcut a archive $1 ;}
|
||||
grep -i /tmp/$1_boxes -e archive | formatShortcut a archive $1
|
||||
spoolfile=$(grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|junk\|archive" | sort -n | sed 1q | sed -e 's/=/+/g')
|
||||
record=$(grep -i /tmp/$1_boxes -e sent | sed -e 's/=/+/g')
|
||||
postponed=$(grep -i /tmp/$1_boxes -e draft | sed -e 's/=/+/g')
|
||||
echo "set spoolfile = \"$spoolfile\"" >> "$muttdir"accounts/$1.muttrc
|
||||
echo "set record = \"$record\"" >> "$muttdir"accounts/$1.muttrc
|
||||
echo "set postponed = \"$postponed\"" >> "$muttdir"accounts/$1.muttrc ;}
|
||||
|
||||
# Sees what accounts have been generated bny the wizard
|
||||
# by checking ~/.offlineimap and yields a menu of them.
|
||||
@ -146,8 +171,6 @@ wipe () { rm $HOME/.offlineimaprc
|
||||
rm -f "$muttdir"credentials/*gpg
|
||||
rm "$muttdir"personal.muttrc ;}
|
||||
|
||||
|
||||
|
||||
while : ;
|
||||
do
|
||||
choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" \
|
||||
@ -166,7 +189,7 @@ case $choice in
|
||||
$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
|
||||
" 6 60;;
|
||||
1) addChosen;;
|
||||
2) inventory && for i in $userchoices; do detectMailboxes $1 ; done &&exit;;
|
||||
2) detectWarning && inventory && for i in $userchoices; do detectMailboxes $i ; done && detectSuccess;;
|
||||
3) inventory && for i in $userchoices; do removeAccount $i ; done;;
|
||||
4) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
|
||||
5) clear && break
|
||||
|
Loading…
Reference in New Issue
Block a user