blob: 16cc01c5792d6ecc43eea0a70562a5c5ea244dd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!@zsh@/bin/zsh
set -xe
function notmuch {
NOTMUCH_TCP=${NOTMUCH_TCP:-2011} @notmuchtcp@/bin/notmuch-tcp ${@}
}
function browser {
${BROWSER:-firefox} ${@}
}
maxCount=0
if [[ -n "$1" && "$1" == <-> ]]; then
maxCount="$1"
fi
count=0
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
url=$(notmuch show --format=mbox $thread | @gnused@/bin/sed -r '/^X-RSS-URL: /!d; s/^X-RSS-URL: (.*)$/\1/')
count=$((count + 1))
if [[ -n "${url}" ]]; then
browser ${url} && notmuch tag -unread -inbox -- $thread
fi
if [[ ${maxCount} -gt 0 && ${count} -ge ${maxCount} ]]; then
exit 0
fi
done
|