kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

Generating lazy completion scripts for Bash/Zsh #473

Closed segevfiner closed 4 months ago

segevfiner commented 4 months ago

It would be nice to be able to generate lazy loaded completion scripts for Bash and Zsh instead of having to eagerly register and execute them at shell startup by register-python-argcomplete. For Bash, it is likely the existing script can be used as is, for Zsh, you need #compdef <command> as the first line and to not call compdef but rather call the completion function directly, there is probably a trick or two to make the script work as both. I think click-completion uses one https://github.com/click-contrib/click-completion/blob/master/click_completion/zsh.j2, and also cobra https://github.com/spf13/cobra/blob/main/zsh_completions.go, but there are also others, not sure which is the best.

kislyuk commented 4 months ago

Yes, that would be nice. PRs are welcome.