zshenv’s selling point isn’t necessarily that your typical functions are available across scripts (though that can be neat, too – I source aliasrc as well as an utils script file in my shell config) – it’s that it’s there for non-interactive shells too, whereas zprofile is only applied for login shells (and zshrc only for interactive ones).
So for example, I could open a command in my editor of choice (Helix’s :sh for me), and if I define stuff using the zshenv, all of my aliases etc. are right there. I just have to avoid naming conflicts for script function names if it’s the default shell, but that’s pretty easily done.
zshenv
’s selling point isn’t necessarily that your typical functions are available across scripts (though that can be neat, too – I sourcealiasrc
as well as anutils
script file in my shell config) – it’s that it’s there for non-interactive shells too, whereaszprofile
is only applied for login shells (andzshrc
only for interactive ones).So for example, I could open a command in my editor of choice (Helix’s
:sh
for me), and if I define stuff using thezshenv
, all of my aliases etc. are right there. I just have to avoid naming conflicts for script function names if it’s the default shell, but that’s pretty easily done.