I wasn't able to find a documentation for the widely used autoload command in zsh. Does anybody can explain it in plain English?
A bit more specific: What does autoloading of modules mean, for example in this line:
autoload -Uz vcs_info
What does it do?
I've tried autoload --help, man autoload, googling - no success. Thanks!
The
autoloadfeature is not available in bash, but it is inksh(korn shell) andzsh. Onzshseeman zshbuiltins.Functions are called in the same way as any other command. There can be a name conflict between a program and a function. What
autoloaddoes is to mark that name as being a function rather than an external program. The function has to be in a file on its own, with the filename the same as the function name.The
-Umeans mark the functionvcs_infofor autoloading and suppress alias expansion. The-zmeans usezsh(rather thanksh) style. See also thefunctionscommand.Edit (from comment, as suggested by @ijoseph):
So it records the fact that the name is a function and not an external program - it does not call it unless the
-Xoption is used, it just affects the search path when it is called. If the function name does not collide with the name of a program then it is not required. Prefix your functions with something likef_and you will probably never need it.For more detail see http://zsh.sourceforge.net/Doc/Release/Functions.html.