-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add shell completion scripts #40
Comments
Using the cobra generated bash completion is ended up being rather difficult to use in conjunction with git's bash completion. Moreover, bash completion is clearly well beyond my meager mind. I did put up some work at making a completion script by hand in e1afa8b which supports completing the commands but not the arguments. |
It would be nice to create zsh completions as well. |
I'm working on completions for fish, which is actually fairly straightforward, but it's also all manual and ... a little tedious. I see that there is a pending PR to enable fish completions in cobra but I'm still too fresh to go and cobra to understand what the docs are saying. I'll post my completions when I get them settled. |
Can't make any promises, but Ill try and run the code in that PR and generate the fish completion for you. Hopefully it'll at least be a good jumping off point, but if it's generating good completions then we might be able to poke some folks for a merge |
Something to keep in mind here is that lab will no longer be a git wrapper in 1.0 -- instead we'll aim to use "git extensions" (or w/e their called) with aliases in git to achieve the same result. Hopefully this should simplify the completetion problem dramatically. In any cases it's likely not worth the headache to get completions working in conjunction with gits completions. I'd suggest focusing on just completing labs commands |
@claytoncarter an example of using cobras completion generators can be seen in https://github.com/zaquestion/lab/pull/205/files |
Thanks, and that makes sense, especially if completions are a pain to get right in bash. FWIW, fish makes it trivial to "inherit" completions from other commands: |
👀 !! |
Got some basic zsh completion working: https://github.com/rsteube/lab-completion |
@rsteube Thats exciting, if the completions work I'm open to merging the changes into lab (even if that means using a fork of cobra). I'm sure the community would really appreciate completion scripts. P.S. If you can do the same thing for bash I'd deeply appreciate it ❤️ |
I would be very happy to use this in zsh! |
I don't know much yet about how to do the argument completion in bash, but the command completion can be generated with cobra pretty easy. I just need to do some cleanup, since i abused some stuff meant for bash in cobra for the zsh generation. Will have a look at it. |
Excellent work, @rsteube! Now that you've given an inch, may I ask for a mile? 😄 Any chance you would take a look at merging spf13/cobra#754 into your fork of cobra so that we can try adding fish completions, too? It looks like that PR only adds new files, doesn't change any code, and adds the |
I think we pretty much have this at this point, always room to improve, but I've been enjoying autocomplete on commands for some time now. |
Cobra has some docs on generating autocompletion scripts for bash: https://github.com/spf13/cobra/blob/master/bash_completions.md
The text was updated successfully, but these errors were encountered: