#!/usr/bin/env bash
# Notmuch post-new hook

# This hook is invoked by the new command after new messages  have
# been  imported  into the database and initial tags have been ap‐
# plied. The hook will not be run if there have  been  any  errors
# during the scan or import.

# Typically  this  hook  is used to perform additional query-based
# tagging on the imported messages.

# TODO: In notmuch v0.35, the location of this hook becomes configurable.
# When I have that installed, I want to move this to ~/.config/notmuch.

# Update tags based on folders
# for fdir in ~/var/mail/fastmail/* ; do
#     if [[ $(basename "$fdir") != "INBOX" ]]; then
#         notmuch tag +$(basename "$fdir") -inbox -- "folder:${fdir##$HOME/var/mail/}"
#     fi
# done

notmuch tag --batch --input="${XDG_CONFIG_HOME:-$HOME/.config}/notmuch/post-new.tags"