-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(cli.rs) Shell completions #4537
Conversation
🕺 |
There's a fix in that PR for a panick the the |
Ahh but I wanted to merge this :(((((((((((((( it's a DX feature and the developer can check the script before enabling it. |
I only tested this on Linux so far. |
I tested on macOS too, maybe we can can signoff from secdude and @nothingismagick regardless. I think this would be pretty uncontroversial. Even though it adds another dependency sooo idk :/ |
I couldn't get it to work on macOS, specially we need it to work when installing with cargo and running with |
True yeah there are many situations where this doesn't work. Let me look into it |
Bit late to the party but for me it works just fine in bash and I'd love to see this merged even if it doesn't work for all shells. I feel it's better to merge a feature that works for some (especially after having sat on the shelf this long) and we can worry about fixing it for non-bash shells later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on Bash just fine and I feel we can fix other shells later.
To use it just run Or, if you're brave, |
For reference here's what I did to use it on ZSH: Append the following to .zshrc:
Run the following:
|
Found a way to fix PowerShell. Note that to use the completions subcommand redirecting output to a file, you must use |
@JonasKruckenberg @simonhyll I've pushed some changes here to make it work on Bash/Zsh/PowerShell. Currently the command outputs the completion script for all package managers (cargo, yarn, npm, pnpm), but we could make it only generate the completion for the current manager too (reduces a lot of the script for non-bash shells). EDIT: actually I don't need all that replace hack, that's better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looooooooooooooooooove this
Ikr?? It's amazing :D Personally I don't think it matters that the output is slightly longer, the default behavior outputting all of them I think is desirable at least. If we want to limit the output to only specific package managers I'd prefer it if we made an option for manually specifying which to output. So something like |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information
This adds a subcommand that can generate shell completions for the following shells: