Alternatively, one can use static named directory. It has the advantage of being expanded at any place, so it works with any command, not just with cd.
Is this approach zsh only?
Yes. AFAIK, bash does not have this.
Wow! I had no idea such a thing existed. Definitely it looks like a more complete solution than mine, although also more complex. Still good to learn something new :)
I also like the words of wisdom thar you can just use shell variables.
You only lose the prompt expansion.
I use zoxide (from the autojump family of tools) and let my computer remember my frequently used directories for me.
(AFAIK autojump inspired j inspired j2 inspired z inspired z.lua inspired zoxide.)
I also use zoxide because it supports both Powershell and fish unlike many of its predecessors
I’ve been using this solution with a slight modification,. It is basically the same idea, but creates custom commands instead of modifying CDPATH.