Frage

Does zsh bash completion support complete -C 'custom command for completion' command?


I had previously written a bash completion function in script, which I enable with

complete -C 'tu --get-bash-completion' tu

I'd like my colleagues who use zsh to be able to use the completion, so I tried testing with a .zshrc file like this for bash completion compatibility:

autoload compinit
compinit
autoload bashcompinit
bashcompinit
complete -C 'tu --get-bash-completion' tu

When I try to use this completion, it looks like zsh is calling the completion script without the arguments bash calls it with (firstword, current_word, previous_word).

tom-mba:~ tomb$ zsh
tom-mba% tu Traceback (most recent call last):
  File "/usr/local/bin/tu", line 7, in <module>
    execfile(__file__)
  File "/Users/tomb/Dropbox/code/TrelloCardUpdate/bin/tu", line 3, in <module>
    cli.CLI()
  File "/Users/tomb/Dropbox/code/TrelloCardUpdate/trellocardupdate/cli.py", line 156, in CLI
    getcompletion(sys.argv[i+1:i+4])
  File "/Users/tomb/Dropbox/code/TrelloCardUpdate/trellocardupdate/cli.py", line 86, in getcompletion
    assert len(args) == 3, [args, sys.argv]
AssertionError: [[], ['/usr/local/bin/tu', '--get-bash-completion']]

I'm using homebrew-installed zsh on a mac:

tom-mba:~ tomb$ zsh --version
zsh 5.0.2 (x86_64-apple-darwin11.4.2)
tom-mba:~ tomb$ which zsh
/usr/local/bin/zsh
War es hilfreich?

Lösung

As of Nov 10, 2013, zsh's bashcompinit doesn't make complete work like this. Apparently compadd -U is the zsh way to have the fine-grained level of control over completion where a script determines exactly what matches to suggest.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top