-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How would I create a custom Zsh Completion, but for another shell? #771
Comments
This is a bit of a non-answer, so apologies for that; Here's an example of how helm does it, which is another project using Cobra: If you notice, there's not really an intersection of this bash completion script, and go or cobra. The commands and arg sets look to be hardcoded in. Not only that, but for me, it's a bit hard to follow. Being curious since you mentioned it, I wondered how it works for zsh since that's my shell of choice, and I stumbled on this very helpful guide: I think this guide articulates how to go about writing a completion script, but still falls short of providing a simple, succinct example. I think that this article provides a good starting point, where you can craft a simple completion script, then turn to the in-depth how to for more advance methods/functionality: |
Thanks @ryanhartje. I'm new to golang, I saw in the the cobra code base the zsh completion code they use. I don't know enough about pointer receivers yet. My plan was to take that code and modify it to what I need. Coming from an OOP background, it looked to me that I would need to add my code to the base cobra code in order to traverse the Is that true? Or can I iterate over the |
This issue is being marked as stale due to a long period of inactivity |
@dfinke Cobra now supports auto-completion for 4 different shells: If this addresses your need, can this issue be closed? |
Closing due to inactivity. Feel free to reopen if you still need help. |
I would like to take my commands and provide the user a way to auto gen completions in a format for another shell. Are there examples on how to do this?
Thank you
The text was updated successfully, but these errors were encountered: