100 Days of Code: Day 06

The way I implemented caching was flawed. I cached the entire formatted directory, for example:

# this is: -t c6 --pre '%F{magenta}'
__prompt_dir_glob__cache[/tmp/something]='%F{magenta}somet\u2025'

This will break if the user wants the last directory to always be not-truncated.

So, we now cache only the glob that matches, and check prefix/suffix/truncate every time.

The second thing I did was to split ::add_glob out to its own file, and add a --help for it.

Finally, I also renamed things to use underscores. While I prefer hyphens in functions, the P10K API requires segments to be called prompt_$name. To prevent confusion, I just renamed everything. I may revert this in the future, though.