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
Include/exclude searched files with implicit wildcard or regex (ag -G) #2314
Comments
It would be good to search the tracker first... :-) Dupe of #48, #54, #75, #91 (lots of discussion here), #193, #285. There's just so many different ways to already do this that I don't see the point of adding a new flag for it. You could also use a purpose driven tool specifically for searching by file name: https://github.com/sharkdp/fd/ |
@BurntSushi I wasn't referring to file search, but filtering files included in result ( Updated the title to be less confusing |
Ooooo, I see. Sorry, I missed that. I'll re-open this for now. I don't have time to respond, but I'm not quite inclined to accept this, at least as of now. ripgrep needs its filtering internals (and interface) overhauled at some point, so I'd rather not add anything substantially new to it as of now. |
Minimalistic POSIX-compatible script with wildcard support: #!/bin/sh
PATTERN="$1"
shift
(for DIR in "${@:-.}"; do rg --files "$DIR"; done) | rg "$PATTERN" |
Describe your feature request
First, thanks for ripgrep.
There is one feature in silversearcher (ag) that's holding me back - filter file paths with regex e.g.
ag <pattern> -G <regex>
.ripgrep seems to support only globs (I'm guessing for performance reasons?)
99% of the time I simply use it to do a partial match, so having something like
rg -G test func
as shortcut torg -g '*test*' func
would totally resolve it for me.So this boils down to:
-G <glob>
that's similar to-g <glob>
but<glob>
is implicitly surrounded with wildcards? Then you could avoid typing and escaping*
in most cases.e.g.
rg -G test func
would be equivalent torg -g '*test*' func
rg -G <pattern>
could accept a regex which would allow other use cases in addition to partial match.Would you consider a PR for the first approach?
Thanks!
The text was updated successfully, but these errors were encountered: