Click the blue text:
So you just need to add that little escape sequence to your prompt so that Terminal knows where you are. Easy!
Or, if you think that's a little cryptic, let's take a look at how bash manages to pull it off. Checking
man bash reveals that when bash is invoked as an interactive login shell (this should be the default when opening a Terminal window or tab), one of the files it references is
A quick peek at
/etc/profile shows that it may load
And looking inside
/etc/bashrc shows that it tries to load
/etc/bashrc_$TERM_PROGRAM. Quick check:
> echo $TERM_PROGRAM
less /etc/bashrc_Apple_Terminal later, and jackpot! Right up near the top:
# Tell the terminal about the current working directory at each prompt.
Followed by a function that does just that, ripe for inclusion in a (bash) prompt. I'm going to refrain from copying the function here, as I'm not entirely sure of the legality of doing so, though I will include the last line of the function, as I believe that's trivial enough to be fair use:
printf '\e]7;%s\a' "file://$HOSTNAME$url_path"
This is basically that cryptic escape sequence from the preferences window popup. The rest of the function is entirely about setting up the
$url_path variable with the necessary percent_encoding. You'll need to translate that stuff to zsh or just extract it to an external bash script and call that, though firing up a bash instance every time might slow your prompt down a bit.