I am trying to follow Make zsh complete arguments from a file but with a command. Shouldn't matter much.
In /usr/local/share/zsh/site-functions/_foo
I have
#compdef foo
aliases=($(a complicated command here printing everything twice))
_describe aliases aliases
The command when ran alone prints this:
foo foo bar bar this this that that
This seems to create an associative array just fine. When I add echo ${(kv)aliases}
before the _describe aliases aliases
command and run /usr/local/share/zsh/site-functions/_foo
I am getting
foo foo bar bar this this that that
And when I just do ${(k)aliases}
then
foo bar this that
I do not really a description so this would work for me. But, it doesn't work for zsh.
I added
function foo() { echo $* }
autoload _foo
compdef _foo foo
to ~/.zshrc
and after . ~/.zshrc
when I type foo [tab]
I get _foo:2: bad set of key/value pairs for associative array
. I tried changing the command to only print everything once. Same results. I tried changing the command to print "foo:x "
for every foo. Same results. So what about should my program produce for this to work?