What does autostart in zsh do?

I could not find the documentation for the widely used autoload in zsh. Can anyone explain this in plain English?

A little more specifically: what does the autoload of the modules mean, for example, on this line:

  autoload -Uz vcs_info

What is he doing?


I tried autoload --help , man autoload , googling - without success. Thanks!

+10
source share
1 answer

The autoload function autoload not available in bash, but it is in ksh (korn shell) and zsh . On zsh see man zshbuiltins .

Functions are called just like any other command. There may be a name conflict between the program and the function. What autoload does is autoload this name as a function, not as an external program. The function must be in a separate file, the file name must match the name of the function.

 autoload -Uz vcs_info 

-U means mark the vcs_info function for autoload and suppress the alias extension. -z means using the zsh style (not ksh ). See also the functions command.

Edit (from the comment as suggested by @ijoseph):

Thus, it captures the fact that the name is a function, and not an external program - it does not call it, if the -X option is not -X , it simply affects the search path when it is called. If the function name does not match the program name, this is not required. Add something like f_ to your functions and you'll probably never need it.

For more information, see http://zsh.sourceforge.net/Doc/Release/Functions.html .

+14
source

Source: https://habr.com/ru/post/989119/


All Articles