-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Shell completion #10058
Shell completion #10058
Conversation
bump? |
@timfallmk thanks for this PR. Shell completion would be nice. Do you know if there's a way to support subcommands? I see that (if installed) this would complete |
@patrickxb That's a good point. The default completion command is pretty limited. It should be pretty trivial to write a completion function that descends through any subcommand trees as well. If that's of interest I'd be happy to look into it. |
@patrickxb Actually I might be wrong. It's possible that this works as intended already. I'll double check and report back. Edit: Confirmed subcommands are also added! |
🆙 |
That's cool. When I tried it, it only generated completions for the root commands. Can you show me the generated file with the subcommands? |
@patrickxb Source pulled directly from here. Added to PROG=keybase source /path/to/bash_autocomplete |
If this isn't of any interest, I'll close out the PR. |
A slightly easier way to get the completion per the CLI library's directions now that the
The reason I prefer to use the |
Note for homebrew users of bash-completion2: drop the keybase script in |
A simple WIP PR to enable basic shell completion using
urfave/cli
's built in shell completion function.The method has two parts:
--generate-<shell>-completion
function that outputs the inline subcommands for the above script.I've enabled the second part (it's just one line), but the first would need to be distributed in some way along with the CLI. Since I don't know your install methods, any insight here would be appreciated.
For an example of how this can be done in practice, see here
If approved,
zsh
completion can easily be added along withbash
.References: