-
Notifications
You must be signed in to change notification settings - Fork 951
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
generate-shell-completion: generate uvx
shell completions for the fish shell
#7323
Conversation
f7f99e4
to
359cc08
Compare
The next commit will be easier to do in the `uv-cli` crate since it explicitly depends on `clap-complete`.
Another approach to this would be to make a |
I think that for bash, you want the uv and uvx completion to end up in different files, because completion is lazy loaded by filename. There might be some way to work around, that, however -- the recommended way seems to be to put the whole completion in a file called I know the PR is about another shell, just bringing this up as a concern that could need to be addressed in general in the design. |
The concern about filename that I had for bash, probably applies in a similar way to fish:
|
I think this applies if you want to ship the completions together with the fish shell. I don't think it matters if you follow the instructions and do
I think my statement applies to One situation where your concerns might be much more relevant is for people who package |
I didn't know the docs had those instructions, I can see how it makes it work. I prefer to use bash completions this way and would recommend it to others: BASH_COMPLETION_DIR="$HOME/.local/share/bash-completion/completions"
mkdir -p "$BASH_COMPLETION_DIR"
uv generate-shell-completion bash > "$BASH_COMPLETION_DIR"/uv It sets up lazy loading correctly. If every tool wanted to be called every time you open a shell (to generate completions), it would take a long time, it's not sustainable. |
I would have thought so, but my understanding is that If somebody has a better understanding, let me know! |
This makes it sound like lazy loading, not eager, "and any completions defined are automatically loaded when needed." Now that we know about bash's symlinks, assuming that works for fish too, maybe it's just fine to combine both completion scripts in the same output? It will work with uv's instructions. And the more detailed setups with a file per command can use a symlink from uvx.fish -> uv.fish and so on. |
There is a proof of concept solution here #7388 but it has some small technical complications |
I'm closing this in favor of #7388. |
Cc: #7258
Summary
uv generate-shell-completion fish
will automatically include completion foruvx
.Hopefully, others will contribute something similar to other shells.
Test Plan
I ran
in
fish
and checkeduvx --f<TAB>
expands to the correct options. You can also douvx -<TAB>
.