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

feat: implement shell completion helpers #1075

Merged
merged 10 commits into from
Feb 27, 2025
Merged

Conversation

wolfv
Copy link
Contributor

@wolfv wolfv commented Feb 19, 2025

This is a bit of a starting point to add support for sourcing shell completions in rattler shell.

@ruben-arts
Copy link
Collaborator

Let's merge this while we're working on the pixi implementation, this is untested code that can easily be extended with more features. So let's do it when there is something/one that uses it.

@wolfv
Copy link
Contributor Author

wolfv commented Feb 26, 2025

We need to decide on the API here. We now have a high-level command that is able to source completion files from a given directory.

I think the question is whether the input to the API should be a the final directory (ie. prefix.join(completion_dir) or whether it should be just the prefix, and rattler will stick things together.

The benefit of giving the final dir directly would be that for pixi global we could arrange folders a bit different (e.g. .pixi/completions/bash, .pixi/completions/fish, ...).

Otherwise we would be forced to do: .pixi/completions/share/bash/bash-completions/.... If we give the directory directly, the calling code for pixi shell should look something like:

if let Some(completions_dir) = shell.completions_dir() {
    shell_script.source_completions(prefix.join(completions_dir));
}

WDYT @ruben-arts / @Hofer-Julian ?

@wolfv wolfv force-pushed the shell-completions branch from 8f334cc to ebcca59 Compare February 27, 2025 09:42
@wolfv
Copy link
Contributor Author

wolfv commented Feb 27, 2025

I decided to do the following API:

shell has an completions_dir() -> Option<PathBuf> that returns the default completion folder location.

The sourcing of completions requires to give the full folder to the folder with completions then though. So we can put them into a different location for pixi global.

@wolfv wolfv changed the title feat: start implementing shell completions feat: implement shell completion helpers Feb 27, 2025
@wolfv wolfv merged commit f2bf71c into conda:main Feb 27, 2025
17 checks passed
@baszalmstra baszalmstra mentioned this pull request Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants