Every interactive shell ran `mkdir -p "$(dirname "$HISTFILE")"`, which
forks twice, even though the directory almost always exists. It costs
~10ms on macOS 27.
We now test if the directory exists first and use zsh's `:h` modifier
instead of dirname, so the most of the time no processes are started.
The directory is still created when missing.