I have never considered that before, but I have seen a few people hooking into PROMPT_COMMAND in bash to make some solutions. I see that you’re using zsh, so this might be of interest to you: https://superuser.com/questions/735660/whats-the-zsh-equivalent-of-bashs-prompt-command
I also saw this GitHub repo that looks useful, although it is for bash specifically: GitHub - wolfwoolford/dish: Store and retrieve directory specific shell history
Finally, an interesting StackOverflow for you to check out for zsh specifically https://unix.stackexchange.com/questions/71189/per-directory-history-in-zsh.






















