This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.config/notmuch/default/hooks/pre-sync.sh

28 lines
861 B
Bash
Executable File

#!/usr/bin/env sh
# Archive files that are NOT tagged Inbox
accounts="david.julien@univ-nantes.fr"
# Update paths & tags
notmuch new --no-hooks
filter() {
notmuch search --output=files --format=text0 $parameters and tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/new/"
notmuch search --output=files --format=text0 $parameters and not tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/cur/"
}
for account in $accounts
do
tags_location="$XDG_CONFIG_HOME/notmuch/tags/$account"
tags="$(grep "+" "$tags_location" | sed -e 's/^.//' -e 's/ .*//')"
for tag in $tags
do
[ "univ" = $tag ] && continue
parameters="folder:$account/INBOX and tag:$tag"
filter
done
done
# Update paths
notmuch new --no-hooks