diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2020-03-07 16:27:55 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2020-03-07 16:27:55 +0100 |
commit | c9f21862006f50937f22f51155ee81ff47399730 (patch) | |
tree | 143817679d60a8b50de7c7730ca08170c0dc8927 /notmuch-links | |
parent | c39a6086a83c2547534d943e3611c4ce0524fafa (diff) | |
download | utils-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-links | 30 |
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 | |||
3 | set -xe | ||
4 | |||
5 | function notmuch { | ||
6 | NOTMUCH_TCP=${NOTMUCH_TCP:-2011} @notmuchtcp@/bin/notmuch-tcp ${@} | ||
7 | } | ||
8 | |||
9 | function browser { | ||
10 | ${BROWSER:-firefox} ${@} | ||
11 | } | ||
12 | |||
13 | maxCount=0 | ||
14 | if [[ -n "$1" && "$1" == <-> ]]; then | ||
15 | maxCount="$1" | ||
16 | fi | ||
17 | |||
18 | count=0 | ||
19 | for 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 | ||
30 | done | ||