Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh completion difference

I have seen many do this
autoload -Uz compinit
compinit

and others do this
autoload -U compinit
compinit -i

I would like to know the difference. which one should I use?

like image 902
pvinis Avatar asked Sep 24 '12 18:09

pvinis


People also ask

What is zsh completion?

`Completion' is where you hit a particular command key (TAB is the standard one) and the shell tries to guess the word you are typing and finish it for you --- a godsend for long file names, in particular, but in zsh there are many, many more possibilities than that.

Where do I put zsh completion files?

Installing Zsh Completions Your completion script must have the following filename format: _example . Next, create a directory at ~/. zsh/completion and copy the completion script to the new directory.

Can zsh use bash completion?

Zsh can handle bash completions functions. The latest development version of zsh has a function bashcompinit, that when run will allow zsh to read bash completion specifications and functions. This is documented in the zshcompsys man page. To use it all you need to do is run bashcompinit at any time after compinit.

How do I turn on autocomplete on zsh?

zsh-autocomplete adds real-time type-ahead autocompletion to Zsh. Find as you type, then press Tab to insert the top completion, Shift Tab to insert the bottom one, or ↓ / PgDn to select another completion. Enjoy using this software?


1 Answers

autoload, from man zshbuiltins:

The flags -z and -k mark the function to be autoloaded in native or ksh emulation, as if the option KSH_AUTOLOAD were unset or were set, respectively.

The -U flag can be traced back: autoload is equivalent to function -u, which is equivalent to typeset -f. typeset, in a nutshell, is used to:

Set or display attributes and values for shell parameters.

When -f is used in combination with -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 is the completion initialization function used by compsys, the 'newer' Z-Shell completion system. See man zshcompsys for details.

The -i flag is used to:

to make compinit silently ignore all insecure files and directories use the option -i

In general, you should be using autoload -Uz, according to this interesting read.

like image 57
simont Avatar answered Sep 27 '22 21:09

simont