zsh: `source` command doesn't reload functions

Sourcing an rc file rarely if ever works in practice, because people rarely write them to be idempotent. A case in point is your own, where you are prepending the same directory to the fpath path every time, which of course means that searching that path takes a little longer each time. No doubt this isn't the only place where you are doing that sort of thing, moreover.

You also do not understand autoloading correctly. As the doco states, autoloading of a function without a body happens the first time that the function is executed. Obviously, if the function is already loaded, and thus has a body, it does not get loaded again.

You need to unfunction the function before autoloading it again.

The sample .zshrc in the Z shell source contains an freload() function that does this very thing for all of the functions named as its arguments. It also does typeset -U path cdpath fpath manpath, notice.


While autoload marks a name for autoloading on first reference in zsh, it doesn't redefine any existing function with the same name should it already be defined, since the name has already been referenced once it was defined. in order to achieve what you desire, you would have to undefine the function first before sourcing .zshrc again or for something more streamline, create a wrapper function for autoload to check if any function names given are already defined and if so, undefine them before marking them for autoload again.

As to why sourcing your .zshrc became slower after each attempt, that isn't answerable without said .zshrc.