diff --git a/config/neomutt/folder-hooks.sh b/config/neomutt/folder-hooks.sh index 53f4269..a2a4eda 100755 --- a/config/neomutt/folder-hooks.sh +++ b/config/neomutt/folder-hooks.sh @@ -1,7 +1,17 @@ #!/bin/sh +usage() { + echo "$0 " + echo " Generate mutt folder hooks for every maildir account in \$folder" + exit 1 +} + +if [ -z "$1" ]; then + usage +fi + acc_dir="$HOME/.config/neomutt/accounts/" -mail_dir="$HOME/mail/" +mail_dir="$1" # Select default account default="$(find "$acc_dir" -name "*.mail" -printf "source '%p'\n" -quit)" diff --git a/config/neomutt/mailboxes.sh b/config/neomutt/mailboxes.sh new file mode 100755 index 0000000..ec26d21 --- /dev/null +++ b/config/neomutt/mailboxes.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +usage() { + echo "$0 " + 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 diff --git a/config/neomutt/neomuttrc b/config/neomutt/neomuttrc index b8dfe1a..19f13d3 100644 --- a/config/neomutt/neomuttrc +++ b/config/neomutt/neomuttrc @@ -3,7 +3,7 @@ set mbox_type = Maildir set copy # See also $record (f*ckin recursion) set folder = "~/mail" unmailboxes * -mailboxes `find ~/mail -mindepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '"%p"\0' | xargs -0` +source "~/.config/neomutt/mailboxes.sh $folder|" # Load external configs source sidebar.rc @@ -12,7 +12,7 @@ source gpg.rc source keys.rc # Accounts -source '~/.config/neomutt/folder-hooks.sh|' +source "~/.config/neomutt/folder-hooks.sh $folder|" # Basic options unset wait_key # Only wait if command exited != 0