我看到很多人这样做
autoload -Uz compinit
compinit
和其他人这样做
autoload -U compinit
compinit -i
我想知道这个区别.我应该使用哪一个?
autoload -Uz compinit
compinit
和其他人这样做
autoload -U compinit
compinit -i
我想知道这个区别.我应该使用哪一个?
解决方法
自动加载,从
man zshbuiltins
:
The flags
-z
and-k
mark the function to be autoloaded in native or ksh emulation,as if the optionKSH_AUTOLOAD
were unset or were set,respectively.
-U标志可以追溯到:autoload等效于功能-u,这相当于排版-f.简而言之,排版用于:
Set or display attributes and values for shell parameters.
当-f与-U组合使用时:
[The -f flag causes] The names refer to functions rather than parameters. … The -u and -U flags cause the function to be marked for autoloading; -U also causes alias expansion to be suppressed when the function is loaded.
compinit是compsys使用的完成初始化函数,“较新的”Z-Shell完成系统.详见man zshcompsys
.
-i标志用于:
to make compinit silently ignore all insecure files and directories use the option -i
一般来说,您应该使用autoload -Uz,根据this interesting read.