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

Bash autocompletion #327

Closed
jack6th opened this issue Dec 5, 2023 · 4 comments
Closed

Bash autocompletion #327

jack6th opened this issue Dec 5, 2023 · 4 comments
Labels
enhancement New feature or request question A question that has or needs further clarification

Comments

@jack6th
Copy link

jack6th commented Dec 5, 2023

ugrep is good tool and it has so many command line options.
Is there a bash auto completion script available?

@genivia-inc genivia-inc added the question A question that has or needs further clarification label Dec 5, 2023
@genivia-inc
Copy link
Member

Thank you for your suggestion.

Bash autocompletion sounds a great idea.

@genivia-inc genivia-inc added the enhancement New feature or request label Dec 12, 2023
@genivia-inc
Copy link
Member

genivia-inc commented Dec 12, 2023

I've written a ugrep bash completion script.

The completion script is located in the ugrep repo completions directory. Please check it out.

I had to jump through some hoops to get long option completion to work properly, e.g. with = arguments completed. No space is allowed after = with ugrep options, so no space is generated by the bash completion. Nevertheless, I will also allow a space after = in the upcoming ugrep release to make it a bit easier to work with long options.

The completion script checks if _init_completion is defined, which should be with bash 4. If not, it exits. This is to avoid issues with older bash e.g. on MacOS.

PS. I'm also updating configure and make install to install bash completions for the ugrep commands.

PPS. For a "usage" overview, instead of 4 examples, perhaps a list of options with one-line descriptions would be better? Feel free to suggest/recommend.

@genivia-inc
Copy link
Member

See also #198 for progress on fish and zsh completion.

@genivia-inc
Copy link
Member

Completed and included in the latest commit. Will be released as an official release in the next release cycle.

This update performs bash completions for the ug, ug+, ugrep, and ugrep+ commands. It also suggests option argument values for -t (--file-type=), --encoding=, -D (--devices=), -d (--directories=), --hexdump=, --sort=, and -Z (--fuzzy=). Note that the = is mandatory with long option argument values.

genivia-inc added a commit that referenced this issue Dec 18, 2023
- installs bash autocompletion #327
- installs fish and zsh autocompletions #198
- TUI ALT-SHIFT-% switches between "bool lines" mode, "bool files" mode and off
- TUI boolF mode (`-%FQ`) now applies syntax highlighting
- option `-t` (`--file-type`) now also accepts filename extensions as shortcuts, when unambiguous, for example `-tpy` for `-tpython` #333
- support legacy grep long options without `=` for option arguments, like GNU grep does
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question A question that has or needs further clarification
Projects
None yet
Development

No branches or pull requests

2 participants