diff options
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 | ||
