mailbox wizard added
This commit is contained in:
parent
d77d46a97c
commit
6f68023133
22
detect_mailboxes.sh
Normal file
22
detect_mailboxes.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/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,6 +2,25 @@
|
||||
|
||||
muttdir="$HOME/.config/mutt/"
|
||||
|
||||
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
|
||||
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 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 ;}
|
||||
|
||||
# Sees what accounts have been generated bny the wizard
|
||||
# by checking ~/.offlineimap and yields a menu of them.
|
||||
inventory() { \
|
||||
@ -132,12 +151,13 @@ wipe () { rm $HOME/.offlineimaprc
|
||||
while : ;
|
||||
do
|
||||
choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" \
|
||||
--menu "What would you like to do?" 14 45 5 \
|
||||
--menu "What would you like to do?" 13 45 6 \
|
||||
0 "List all email accounts configured." \
|
||||
1 "Add an email account." \
|
||||
2 "Remove an email account." \
|
||||
3 "Remove all email accounts." \
|
||||
4 "Exit this wizard." \
|
||||
2 "Auto-detect mailboxes for an account." \
|
||||
3 "Remove an email account." \
|
||||
4 "Remove all email accounts." \
|
||||
5 "Exit this wizard." \
|
||||
3>&1 1>&2 2>&3 3>&1 )
|
||||
|
||||
|
||||
@ -146,8 +166,9 @@ case $choice in
|
||||
$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
|
||||
" 6 60;;
|
||||
1) addChosen;;
|
||||
2) inventory && for i in $userchoices; do removeAccount $i ; done;;
|
||||
3) (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) ;;
|
||||
4) clear && break
|
||||
2) inventory && for i in $userchoices; do detectMailboxes $1 ; done &&exit;;
|
||||
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
|
||||
esac
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user