Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trouble trying to understand zsh's completion system



Filipe Silva wrote on Wed, 11 Oct 2017 07:37 -0300:
> So I saved this file as _gocomp in a directory:
> 
> #compdef go
> 
> local -a options
> options=('run:description for run' 'build:description for build')
> _describe 'values' options
> 
> after $ fpath=($(readlink -f .) $fpath) and autload -U _gocomp, I try to
> type go [TAB]. zsh greets me with `go _gocomp`.
> 
> What am I doing wrong?

You aren't making the link between the command "go" and the autoloadable
function "_gocomp".

You can do that either by running compinit after changing fpath (then
you don't need to run autoload explicitly) or by running 'compdef
_gocomp go' in addition to what you're running.

It completes "_gocomp" because that's the only file in the current
directory.  (_files is the default completion)

Minimal example:

zsh -f
autoload compinit
compinit
_foo() { compadd bar }
compdef _foo foo
foo <TAB>

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author