summaryrefslogtreecommitdiffstats
path: root/.bin
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2022-01-04 18:16:12 +0100
committerRomain Gonçalves <me@rgoncalves.se>2022-01-04 18:16:12 +0100
commite7b2188fe8dd715603dbd509fc62de6e872933a2 (patch)
tree8f31b14f0958d2b7acc9c41f940156e0822f22c4 /.bin
parentf7ba6813339a00e45959c10c96b249326419c10b (diff)
downloaddots-e7b2188fe8dd715603dbd509fc62de6e872933a2.tar.gz
Tue Jan 4 06:16:12 PM CET 2022
Diffstat (limited to '.bin')
-rwxr-xr-x.bin/get-mailbox-imap34
-rwxr-xr-x.bin/get-mailbox-local11
-rwxr-xr-x.bin/nmutt5
3 files changed, 25 insertions, 25 deletions
diff --git a/.bin/get-mailbox-imap b/.bin/get-mailbox-imap
index 713873e..b78752d 100755
--- a/.bin/get-mailbox-imap
+++ b/.bin/get-mailbox-imap
@@ -5,25 +5,17 @@ import sys
def get_boxes(list):
- """
- Retrieve and decode all mailboxes.
- """
+ """ Retrieve and decode all mailboxes. """
return [box.decode('utf-8').rsplit(' ')[-1] for box in list]
def flatten_output(list):
- """
- Print all boxes with a flattened output,
- primarily for neomutt usage.
- """
+ """ Print all boxes with a flattened output. """
return ''.join([f"+'{box}' " for box in list])
-def sort_boxes(bxs):
- """
- Sort boxes list,
- according to a predefined order
- """
+def sort_mailboxes(mailboxes):
+ """ Sort boxes list according to a predefined order. """
order = [
"INBOX",
@@ -36,20 +28,20 @@ def sort_boxes(bxs):
"Archive"
]
- bxs_orig = sorted(bxs)
+ mailboxes = sorted(mailboxes)
# sort based on predefined order
- bxs = []
+ output = []
for exp in order:
- matching = [s for s in bxs_orig if exp in s]
- bxs.extend(matching)
+ matching = [s for s in mailboxes if exp in s]
+ output.extend(matching)
# ensure all retrieved boxes are present
- for bx in bxs_orig:
- if bx not in bxs:
- bxs.append(bx)
+ for box in mailboxes:
+ if box not in output:
+ output.append(box)
- return bxs
+ return output
def main():
@@ -67,7 +59,7 @@ def main():
mail.login(username, password)
# parse folders output
- bxs = sort_boxes(get_boxes(mail.list()[1]))
+ bxs = sort_mailboxes(get_boxes(mail.list()[1]))
# oneline pretty-print for neomutt
print(flatten_output(bxs), end=' ')
diff --git a/.bin/get-mailbox-local b/.bin/get-mailbox-local
new file mode 100755
index 0000000..b579016
--- /dev/null
+++ b/.bin/get-mailbox-local
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+root_dir=$(readlink -f ${1})
+
+mailboxes=$(find "${1}" -name "cur" |
+ xargs dirname |
+ sed "s@$root_dir/@+@g" |
+ grep "${2:-.*}" |
+ sort)
+
+echo ${mailboxes}
diff --git a/.bin/nmutt b/.bin/nmutt
index 2ea8170..f8172b1 100755
--- a/.bin/nmutt
+++ b/.bin/nmutt
@@ -15,8 +15,5 @@ export MAIL_SERVER=$(get_param "${NMUTT_CONFIGURATION_FILE}" "my_server")
export MAIL_USERNAME=$(get_param "${NMUTT_CONFIGURATION_FILE}" "my_user")
export MAIL_PASSWORD=$(get-pass "mailbox")
-# get-mailbox-imap imap.${MAIL_SERVER} ${MAIL_USERNAME}@${MAIL_SERVER} ${MAIL_PASSWORD}
-# offlineimap --dry-run
-mbsync -a
-
+notmuch new
exec neomutt ${@}
remember that computers suck.