Click: Autocomplete support for zsh

Created on 8 Apr 2015  路  6Comments  路  Source: pallets/click

Bash autocompletion works well, but I would really like zsh to work as well

Most helpful comment

As an alternative to implementing native zsh completion, you can also use zsh's bash completion compatibility mode. To use it, add

autoload bashcompinit
bashcompinit
eval "$(_FOO_BAR_COMPLETE=source foo-bar)"

to your .zshrc. The last line assumes your click script is called foo-bar; see the click docs for more info.

All 6 comments

Related https://github.com/mitsuhiko/click/issues/241.

Has zsh implementation: https://github.com/kislyuk/argcomplete

I have to release a tmuxp.bash, tmuxp.zsh and tmuxp.tcsh to get autocomplete working with argcomplete. The user has to source the correct one depending on their $SHELL, https://github.com/tony/tmuxp/tree/master/pkg

See also aws-cli's advanced completion: https://github.com/aws/aws-cli/tree/develop/bin

The user has to source the correct one depending on their $SHELL

if their $SHELL is zsh and you install globally, you can just put _tmuxp into $fpath, which by default contains /usr/{,local/}share/zsh/site-functions.

As an alternative to implementing native zsh completion, you can also use zsh's bash completion compatibility mode. To use it, add

autoload bashcompinit
bashcompinit
eval "$(_FOO_BAR_COMPLETE=source foo-bar)"

to your .zshrc. The last line assumes your click script is called foo-bar; see the click docs for more info.

@bb4242 thanks for the tipp, that works well.

@bb4242's answer should be added to the docs at: http://click.pocoo.org/5/bashcomplete/

Closed since we have two related pull requests with active discussion and development

865 and #869

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dploeger picture dploeger  路  18Comments

mahmoudimus picture mahmoudimus  路  25Comments

cooperlees picture cooperlees  路  11Comments

stevekuznetsov picture stevekuznetsov  路  21Comments

omribahumi picture omribahumi  路  14Comments