rc/config/neomutt/mailboxes.sh

23 lines
608 B
Bash
Raw Normal View History

#!/bin/sh
usage() {
>&2 echo "$0 <neomutt \$folder>"
>&2 echo " Generate neomutt mailboxes & named-mailboxes for every maildir in \$folder"
exit 1
}
if [ -z "$1" ]; then
usage
fi
maildir="$1"
mailboxes=$(find "$maildir" -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch)
for m in $mailboxes; do
inbox="$(find "$m" -maxdepth 1 -iname "inbox" -type d -printf "%f" -quit)"
echo "named-mailboxes '$(basename "$m")' '$m/$inbox'"
printf "mailboxes "
find "$m" -mindepth 1 -type d ! -name cur ! -name tmp ! -name new -printf '"%p"\0' | xargs -0
done