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 completion for -g glob #792

Closed
jzinn opened this issue Feb 12, 2018 · 6 comments
Closed

bash completion for -g glob #792

jzinn opened this issue Feb 12, 2018 · 6 comments
Labels
question An issue that is lacking clarity on one or more points.

Comments

@jzinn
Copy link

jzinn commented Feb 12, 2018

What version of ripgrep are you using?

Ripgrep:

$ rg --version
ripgrep 0.8.0 (rev 23d1b91ead)
-SIMD -AVX

Bash:

bash-4.4.12-13.fc27.src.rpm

Bash-completion:

bash-completion-2.6-2.fc27.src.rpm

What operating system are you using ripgrep on?

$ uname -a
Linux ammonite 4.14.16-300.fc27.x86_64 #1 SMP Wed Jan 31 19:24:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release 
Fedora release 27 (Twenty Seven)

Describe your question, feature request, or bug.

Bug: rg -g Foo<tab> should not be replaced with rg -g <GLOB>....

When typing an argument to -g and hitting the tab character, then whatever you have typed for the argument is erased and replaced with the characters <GLOB>.... It would be better not to do anything at all to preserve what was typed.

Even better than doing nothing would be to use file names for completion, so ...

Feature request: rg -g Foo<tab> should use files in the current directory for tab auto-completion in Bash. If possible, it should also work with negation (rg -g "!"Foo<tab>).

For example, the following should work:

touch Foo.txt
rg -g Fo<tab>  # hit tab to initiate completion
rg -g Foo.txt  # after completion

This should also work:

mkdir vendor
rg -g "!"vend<tab>  # hit tab to initiate completion
rg -g "!"vendor     # after completion

If this is a bug, what are the steps to reproduce the behavior?

Make a file:

touch Foo.txt

Attempt to use it with autocomplete:

rg -g Fo<tab>

If this is a bug, what is the actual behavior?

The command line is changed to

rg -g <GLOB>...

If this is a bug, what is the expected behavior?

Either maintain the original command:

rg -g Fo

or use file name:

rg -g Foo.txt
@BurntSushi
Copy link
Owner

This sounds like a clap bug. Completion rules for ripgrep are provided on a best effort basis. Right now, the bash completion rules are automatically generated. I don't personally have the bandwidth to do anything more than that. (We either provide what clap provides, or someone else maintains them (like @okdana has been doing for zsh), or we drop them completely.)

@BurntSushi BurntSushi added the question An issue that is lacking clarity on one or more points. label Feb 12, 2018
@BurntSushi
Copy link
Owner

Thank you for the awesome bug report though. :-)

@jzinn
Copy link
Author

jzinn commented Feb 12, 2018

Thank you for the incredible response time!

@kbknapp
Copy link
Contributor

kbknapp commented Feb 12, 2018

@jzinn would you mind filing a bug at kbknapp/clap-rs please? In general the completion script generation was meant to get to the 95% solution, so they're not perfect. I agree it shouldn't replace anything already typed on the command line with a generic <GLOB>..., and actually should ideally just fallback to file matching.

It should be fairly simple on my end to just remove all generic completions and simply use file completion which I would say is what people expect 99% of the time. Even when it's actually wrong and not what the flag is asking for, it still doesn't surprise people like totally erasing what they wrote and replacing with a generic statement.

@jzinn
Copy link
Author

jzinn commented Feb 13, 2018

Certainly.

@BurntSushi
Copy link
Owner

This appears to have been fixed in clap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question An issue that is lacking clarity on one or more points.
Projects
None yet
Development

No branches or pull requests

3 participants