By default, ZSH hook chpwd
is not triggered on shell startup. The tutorial here provides some ideas to fix this.
We can use a trick to define a function run only once on precmd
and destruct itself automatically.
function _self_destruct_hook {
local f
for f in ${chpwd_functions}; do
"$f"