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.
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
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.