Skip to content
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 completions in pixi global & pixi envs #2366

Open
wolfv opened this issue Oct 29, 2024 · 4 comments
Open

Shell completions in pixi global & pixi envs #2366

wolfv opened this issue Oct 29, 2024 · 4 comments

Comments

@wolfv
Copy link
Member

wolfv commented Oct 29, 2024

This issue concerns pixi, but also the wider conda ecosystem.
I would like to come up with a mechanism to support shell completion files easily.

Shell completions are usually initialized by sourcing a shell script that injects a number of completion functions into the context of the shell.
Homebrew has a pretty solid mechanism to generate & source shell completions and I think we should follow that. Conda also has the "activation" script mechanism, but it is meant for a slightly different purpose and it's also beneficial to not execute shell completion hooks in a context where it's not needed (to keep activation scripts fast).

For these reasons I would like to introduce a new folder $PREFIX/share/<shell>/completions/.
Of course, packages would have to adopt this folder (which is why we should also write a CEP about it).

For bash, zsh or fish, we should create snippets to load all the completions scripts from the folder. And pixi shell should automatically source this snippet.

For pixi global, we should source all relevant snippets (similar to the binary expose function) we should write the completions to be sourced to a file like ~/.pixi/completions/bash/completions.sh. This file would need be kept in sync with any changes.

@pavelzw
Copy link
Contributor

pavelzw commented Oct 29, 2024

for pixi global i feel it might be a bit more stable to write the completions to ~/.pixi/completions/bash/<env-name>.sh and just source all of them in ~/.pixi/completions/bash-completion.sh

@jakirkham
Copy link

Thanks Wolf! 🙏

Yeah this seems like a nice pattern generally

@jezdez
Copy link

jezdez commented Nov 1, 2024

I really like this, thought that is really working well for Homebrew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants