29 lines
861 B
Bash
Executable file
29 lines
861 B
Bash
Executable file
#!/bin/sh
|
|
|
|
usage() {
|
|
>&2 echo "$0 <maildirs \$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 | sort)
|
|
|
|
# Order of the keys to use for the account switch macro
|
|
chars="1234567890azertyuiopqsdfghjklmwxcvbn"
|
|
i=1
|
|
|
|
for m in $mailboxes; do
|
|
inbox="$(find "$m" -maxdepth 1 -iname "inbox" -type d -printf "%f" -quit)"
|
|
key="$(printf '%s' "$chars" | cut -c "$i")"
|
|
printf "named-mailboxes '[%s] %s' '%s'\n" "$key" "$(basename "$m")" "$m/$inbox"
|
|
printf "sidebar_whitelist '%s'\n" "$m/$inbox"
|
|
printf "mailboxes "
|
|
find "$m" -mindepth 1 -type d ! -name cur ! -name tmp ! -name new -printf '"%p"\0' | xargs -0
|
|
i=$((i+1))
|
|
done
|