What's the most efficient way to export the functions/aliases defined in my .zshrc to be used anywhere. For example in my .zshrc
And then invoke _foo in any script.
As suggested in one of the comments, you could put them in the file
/etc/zshenv. However, on many distributions, this file is supplied by the OS. Besides that,
/etc/zshenv is sourced every time your system runs a Zsh script, even when it's not from an interactive shell. Putting too many customizations in
/etc/zshenv has the potential to significantly slow down your system or even break things.
Instead, if your custom functions and aliases are meant for interactive usage only, it is generally wiser to put them into
/etc/zshrc, which is sourced only for interactive shells.