5 ms·
This, and also it ignores irrelevant files. It has sane defaults but you can tweak this with a .rgignore file, which is like .gitignore but for rg. By the way,
by jraph 4y ago
This, and also it ignores irrelevant files. It has sane defaults but you can tweak this with a .rgignore file, which is like .gitignore but for rg. By the way, it will use .gitignore files in a git directory.
That means that by default, it will take a lot less time and won't ruin your terminal when lines of some generated files (especially minified ones that are all on one line) match your search.
This is the main reason I use ripgrep.
- pletnes 4y agoThis. Also you can do stuff like «rg —python myvariable» to search python files only. Neat for multi-language directory trees. (Works with many other languages.)
- js2 4y ago> By the way, it will use .gitignore files in a git directory. If I'm in a repo, I'm using `git grep`. That makes `rg` a mostly redundant tool for me since it's optimized for searching source code. I can't really use it as a general purpose replacement for grep since if it doesn't find anything I'm left wondering whether what I'm searching is not really there or whether `rg` just didn't bother to check. Even with `--no-ignore --all`, I'm still not sure whether it searches everything. It's one of those tools that I find is too clever for my own good. So when `git grep` doesn't cover my use case, my fall back is `find | grep` which contains no magic and I know exactly what it's searching.
- heywoodlh 4y agoWhoa, I didn't even know about `git grep`. Sure enough, `man git-grep` has a bunch of relevant info! Thanks for sharing this. I feel like there are a billion features in git (like this) that I don't know about.
- nicoburns 4y agoIt’s handy if you want to search more than one repo at once. I believe you can do ‘rg -uuu’ as a shorthand to disable all ignores
- mkhnews 4y agoIn particular, ’rg ‐uuu’ should search the same exact content as ’grep ‐r’.
- js2 4y agoThank you. This inspired me to read the ripgrep man page. I think I must have been confusing ripgrep's behavior with the earlier ack (or maybe ag) tool which only searched known extensions by default. I see now that ripgrep only does that if explicitly given a --type option.
- masklinn 4y ago> It has sane defaults but you can tweak this with a .rgignore file, which is like .gitignore but for rg. By the way, it will use .gitignore files in a git directory. Fwiw there’s also a « .ignore » semi-standard which works with several tools, and not just greps e.g. fd also respects it by default.
- atwood22 4y agoDo you know about “git grep”? It’s like grep but only greps files tracked by git. Very useful.
- wonderbore 4y agoWhy use a git-specific tool when a generic one (rg) works just as well, even from a parent directory? I often use rg to search code across repositories so it's useful to have that regardless of grep and git
- Tempest1981 4y agoOften a directory contains a mix of source files (in git) and output files (usually in .gitignore). But maybe rg automatically handles this?
- jraph 4y agoIt does
- jraph 4y agoI didn't, seems worth giving a look.
- deleted 4y ago[deleted]