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: add shell completions #1054

Merged
merged 4 commits into from
Oct 10, 2023
Merged

Conversation

ShaunSHamilton
Copy link
Contributor

@ShaunSHamilton ShaunSHamilton commented Oct 9, 2023

Closes #877

Adds shell completions, by adding a new gix command generate-completions:

gix generate-completions --shell bash --out-dir /tmp
# Source changes
gix <TAB>

I assume the version and CHANGELOG are automatically updated. Also, I am unsure if this should be under feat or BREAKING! - an exhaustive public enum has been changed, but I am not sure how/if it is used as a library.

@Skgland
Copy link

Skgland commented Oct 9, 2023

I don't think this command should assume that the user wants to install the completions system-wide, especially as that requires elevated permission (sudo). Most tools with an option to generate completions that I know output to stdout. This way the user can decide where to place the completions and no elevated permissions are required. I think a few of the tools I know by default add their completions by adding to bashrc and sourcing the output without ever writing to a file. Though that has other implications as the who knows what is sourced each time bashrc is run.

@ShaunSHamilton
Copy link
Contributor Author

I don't think this command should assume that the user wants to install the completions system-wide, especially as that requires elevated permission (sudo).

Fair enough. I just thought this the simplest workflow (requires the least action from the user).

Most tools with an option to generate completions that I know output to stdout.

I have never had to do this for any tools. Do you have an example of one I could look at?

@Skgland
Copy link

Skgland commented Oct 9, 2023

One example would be rustup e.g. rustup completions bash

The help text when running rustup completions without specifying a shell include:
rustup completions bash cargo >> ~/.local/share/bash-completion/completions/cargo for how to setup the completions.
Though I think that is typically also done automatically as part of the rustup installation.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This contributions comes at a surprise but I think it can be made to work.

You could make it so it's very similar if not the same as the same command for atuin.

In general, please do not attempt to auto-install these completions, being able to generate them is a good first step that already helps those who really want it.

@Skgland Please feel free to review as well, I think we want the same.

@ShaunSHamilton ShaunSHamilton changed the title feat: add shell completions for bash feat: add shell completions Oct 9, 2023
@Skgland
Copy link

Skgland commented Oct 9, 2023

I think the latest changes look good 👍

@Byron Byron merged commit 681c607 into GitoxideLabs:main Oct 10, 2023
@Byron
Copy link
Member

Byron commented Oct 10, 2023

Thanks a lot!

@ShaunSHamilton ShaunSHamilton deleted the feat_completions branch October 10, 2023 07:01
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.

Shell completions support
3 participants