For use with mail/neomutt, I need a script that gives me all the directories starting with
I've managed to do this with both the base find(1) as well as misc/findutils. However, both have a drawback: the base find is ridiculously slow at the job, and misc/findutils is a separate port I'm having to put up with just for this one script.
For find(1):
For misc/findutils:
(The detour through sort(1) and paste(1) is needed because GNU find can't do sorting.)
The script runs every time neomutt starts. That's not strictly necessary, but it's a precaution against other clients creating or renaming folders in the ~/Maildir/. I want to be sure that neomutt always polls the folders currently in existence, and not some stale dirlisting from the day before yesterday. It's not practical to call the script everytime a folder gets changed, because there's different clients on different machinves involved. Also, I don't know of an elegant way to monitor the directory for changes and update if a folder changes.
What would you do? Just suck it down and accept that GNU find is needed for the job? Learn to accept the quarter-second delay when opening mail? Something else?
.
in my ~/Maildir/, sorted alphabetically, each prefixed with a +
and separated by a single space. The number of directories is about 300.I've managed to do this with both the base find(1) as well as misc/findutils. However, both have a drawback: the base find is ridiculously slow at the job, and misc/findutils is a separate port I'm having to put up with just for this one script.
For find(1):
find -s ~/Maildir/ -maxdepth 1 -type d -name ".*" -execdir echo -n " +{}" \;
– takes about 230 milliseconds to run.For misc/findutils:
gfind ~/Maildir/ -maxdepth 1 -type d -name ".*" -printf +%f\\n | sort | paste -sd" " -
– takes about 10 milliseconds to run.(The detour through sort(1) and paste(1) is needed because GNU find can't do sorting.)
The script runs every time neomutt starts. That's not strictly necessary, but it's a precaution against other clients creating or renaming folders in the ~/Maildir/. I want to be sure that neomutt always polls the folders currently in existence, and not some stale dirlisting from the day before yesterday. It's not practical to call the script everytime a folder gets changed, because there's different clients on different machinves involved. Also, I don't know of an elegant way to monitor the directory for changes and update if a folder changes.
What would you do? Just suck it down and accept that GNU find is needed for the job? Learn to accept the quarter-second delay when opening mail? Something else?