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

Support "::" in Bash completions #1863

Merged
merged 3 commits into from
Jan 27, 2024
Merged

Conversation

crdx
Copy link
Contributor

@crdx crdx commented Jan 21, 2024

Modules use :: as the separator, which is considered a wordbreak character in Bash. This means they can't be completed by default, as colon is considered the end of a completion.

The (very) bad way to solve this is by globally modifying COMP_WORDBREAKS to remove the colon character. Not only is this bad because it can have unintended side-effects, but git's completion script actually adds the colon back if it detects it's not present.

So Bash made available the _get_comp_words_by_ref and __ltrim_colon_completions functions for this purpose. They're not present on every platform, in which case we fall back to the original method.

@crdx
Copy link
Contributor Author

crdx commented Jan 21, 2024

... oh.

That completion file is generated by clap. Right.

@crdx
Copy link
Contributor Author

crdx commented Jan 21, 2024

Gonna be fun making those changes using only search/replacements in BASH_COMPLETION_REPLACEMENTS.

@crdx crdx marked this pull request as draft January 21, 2024 18:06
@crdx crdx marked this pull request as ready for review January 21, 2024 18:25
@crdx
Copy link
Contributor Author

crdx commented Jan 21, 2024

Should be good now.

@casey casey merged commit e92ee92 into casey:master Jan 27, 2024
5 checks passed
@casey
Copy link
Owner

casey commented Jan 27, 2024

Nice, LGTM!

@crdx crdx deleted the completion-colon-support branch February 11, 2024 23:02
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.

2 participants