aboutsummaryrefslogtreecommitdiff
path: root/mutt-notmuch-tag
blob: 16b81cf9a4a90068eb0191b78999ec4d50a8a99f (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
# mutt-notmuch-tag.sh
# Simple and crude script to tag multiple messagess in mutt using notmuch.
# See http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt/

TMP="$HOME/temp/mutt/misc"

grep "Message-ID" - > $TMP/notmuch-tag-id.txt
sed -e 's|Message-ID:.*<\(.*\)>.*|id:\1|' $TMP/notmuch-tag-id.txt > $TMP/notmuch-tag-tmp.txt
sed '{:q;N;s/\n/ OR /g;t q}' $TMP/notmuch-tag-tmp.txt > $TMP/notmuch-tag-tagged.txt

## When vi opens up list the tagging commands, e.g. +tag1 -tag2
vi $TMP/notmuch-tag-tags.txt

TAGS=`cat $TMP/notmuch-tag-tags.txt`
SEARCHEXPR=`cat $TMP/notmuch-tag-tagged.txt`

## For debugging
echo "notmuch tag $TAGS -- $SEARCHEXPR" >> $TMP/notmuch-tag-tagged.txt

## Now apply the tags
notmuch tag $TAGS -- $SEARCHEXPR

## Cleanup
rm $TMP/notmuch-tag-id.txt
rm $TMP/notmuch-tag-tmp.txt
rm $TMP/notmuch-tag-tags.txt
rm $TMP/notmuch-tag-tagged.txt

# End of mutt-notmuch-tag.sh