2019-11-20 21:08:34 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
usage() {
|
2020-11-11 03:05:37 +00:00
|
|
|
>&2 echo "$0 <maildirs \$folder>"
|
2020-06-19 02:01:14 +00:00
|
|
|
>&2 echo " Generate neomutt mailboxes & named-mailboxes for every maildir in \$folder"
|
2019-11-20 21:08:34 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
maildir="$1"
|
|
|
|
|
2020-11-11 03:05:37 +00:00
|
|
|
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
|
2019-11-20 21:08:34 +00:00
|
|
|
|
|
|
|
for m in $mailboxes; do
|
|
|
|
inbox="$(find "$m" -maxdepth 1 -iname "inbox" -type d -printf "%f" -quit)"
|
2020-11-11 03:05:37 +00:00
|
|
|
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"
|
2019-11-20 21:08:34 +00:00
|
|
|
printf "mailboxes "
|
|
|
|
find "$m" -mindepth 1 -type d ! -name cur ! -name tmp ! -name new -printf '"%p"\0' | xargs -0
|
2020-11-11 03:05:37 +00:00
|
|
|
i=$((i+1))
|
2019-11-20 21:08:34 +00:00
|
|
|
done
|