Open oandrew opened 2 years ago
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. rg --files | rg test
can be easily put into an alias or a wrapper shell script. Here's mine:
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 (rg --glob
). I searched the tracker but didn't find anything similar.
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!