#!/bin/bash # Return responses to message id query # # $ nm-ack id:msgid@domain # id:response1@domain1 id:response2@domain2 ... # # Author: Suvayu Ali # debug # set -o xtrace declare query="$1" thread=$(notmuch search --output=threads -- "$1") declare -a msgs=$(notmuch search --output=messages -- "$thread") responses function strip_mid() { sed -e 's/[<> ]//g' } for m in ${msgs[@]}; do [[ $query == $m ]] && continue r=id:$(notmuch show --format=raw -- $m | formail -x In-Reply-To: | strip_mid) [[ $query == $r ]] && responses+=($m) done echo ${responses[@]}