Frage

I'm writing some zsh completions and am stuck on how to have multiple groups of completions.

I added the group name with the -J parameter docs.

compadd -J group1 "$@" completion1 completion2
compadd -J group2 "$@" completion3 completion4

Then I added the zstyle to my ~/.zshrc docs (heading: group-name)

zstyle ':completion:*' group-name ''

The completions come up fine, but the group names are not being displayed. What am I doing wrong?

War es hilfreich?

Lösung 2

I believe group-name only applies to the command position (i.e. the first one). Myself, I only use compadd directly for custom completion of command options, in this case, it is the -x message that gets used:

Contents of _foo:

#compdef  foo    
A=( -h --help foo bar baz )
compadd -J group1 -X expl1 -x msg1 -a A
B=( clown-fish hippo )                                                   
compadd -J group2 -X expl2 -x msg2 -a B

then somewhere else:

function foo { echo $* }
compdef _foo foo

When I run this completion, I get the options grouped by message.

Andere Tipps

In my case the group names appeared only after adding:

zstyle ':completion:*' group-name ''
zstyle ':completion:*' format 'Completing %d'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top