summaryrefslogtreecommitdiff
path: root/detect_mailboxes.sh
diff options
context:
space:
mode:
authorLuke <luke@lukesmith.xyz>2018-02-13 12:15:43 -0700
committerLuke <luke@lukesmith.xyz>2018-02-13 12:15:43 -0700
commit6f6802313340ba7ed152f0953e1e0a1a43fbd394 (patch)
treee3905fad3f7f081f8f7fd3d9e97b8d9a94b52038 /detect_mailboxes.sh
parentd77d46a97c47cafc594310145256a0e3c24490dc (diff)
mailbox wizard added
Diffstat (limited to 'detect_mailboxes.sh')
-rw-r--r--detect_mailboxes.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/detect_mailboxes.sh b/detect_mailboxes.sh
new file mode 100644
index 0000000..7a015e1
--- /dev/null
+++ b/detect_mailboxes.sh
@@ -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
+