summaryrefslogtreecommitdiff
path: root/notmuch-links
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2020-03-07 16:27:55 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2020-03-07 16:27:55 +0100
commitc9f21862006f50937f22f51155ee81ff47399730 (patch)
tree143817679d60a8b50de7c7730ca08170c0dc8927 /notmuch-links
parentc39a6086a83c2547534d943e3611c4ce0524fafa (diff)
downloadutils-c9f21862006f50937f22f51155ee81ff47399730.tar
utils-c9f21862006f50937f22f51155ee81ff47399730.tar.gz
utils-c9f21862006f50937f22f51155ee81ff47399730.tar.bz2
utils-c9f21862006f50937f22f51155ee81ff47399730.tar.xz
utils-c9f21862006f50937f22f51155ee81ff47399730.zip
bump
Diffstat (limited to 'notmuch-links')
-rw-r--r--notmuch-links30
1 files changed, 30 insertions, 0 deletions
diff --git a/notmuch-links b/notmuch-links
new file mode 100644
index 0000000..16cc01c
--- /dev/null
+++ b/notmuch-links
@@ -0,0 +1,30 @@
1#!@zsh@/bin/zsh
2
3set -xe
4
5function notmuch {
6 NOTMUCH_TCP=${NOTMUCH_TCP:-2011} @notmuchtcp@/bin/notmuch-tcp ${@}
7}
8
9function browser {
10 ${BROWSER:-firefox} ${@}
11}
12
13maxCount=0
14if [[ -n "$1" && "$1" == <-> ]]; then
15 maxCount="$1"
16fi
17
18count=0
19for thread (${(z)$(notmuch search --sort=oldest-first 'tag:inbox AND is:link AND is:unread AND NOT (is:killed or tag:later)' | @coreutils@/bin/tee >(cat >&2) | @gawk@/bin/awk '{ print $1; }')}); do
20 url=$(notmuch show --format=mbox $thread | @gnused@/bin/sed -r '/^X-RSS-URL: /!d; s/^X-RSS-URL: (.*)$/\1/')
21 count=$((count + 1))
22
23 if [[ -n "${url}" ]]; then
24 browser ${url} && notmuch tag -unread -inbox -- $thread
25 fi
26
27 if [[ ${maxCount} -gt 0 && ${count} -ge ${maxCount} ]]; then
28 exit 0
29 fi
30done