News for hackers. Stuff that matters.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by xezian on Thursday November 30, 2023 @09:43AM (#38474102)
I've been using ripgrep for about 2 years now and I find in indispensable. The main reason I switched from grep was ease of use. From the README: "By default, ripgrep will respect gitignore rules and automatically skip hidden files/directories and binary files." Typing `rg search_term directory` is much better than the corresponding grep command, but the speed improvement is also a nice bonus.

Random other helpful flag I use often is -M if any of the matches are way too long to read through and cause a lot of terminal chaos. Just add `-M 1000` or adjust the number for your needs and the really long matches will omit the text context in the results.

Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by hhda on Thursday November 30, 2023 @11:03AM (#38475128)
Yeah, the -M command is wonderful (super handy for ignoring minified files that you don't want to see results from, etc), and also great is the -g command (eg `-g *.cs` and you'll just search in files that have the .cs extension).

Also the fact that it is a standalone portable executable can be super handy. Often when working on a new machine, I'll drop in the executable and an alias for grep that points to rg, so if muscle memory kicks in and I type grep it will still use rg.

Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by 3PS on Thursday November 30, 2023 @11:48AM (#38475714)
If you're a fan of the -g flag to ripgrep then I also recommend checking out the -t flag, short for --type, which lets you search specific file types. You can see the full list with `rg --type-list`. For example, you could just search .cs files with `rg -tcs`.

This flag is especially convenient if you want to search e.g. .yml and .yaml in one go, or .c and .h in one go, etc.

Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by hhda on Thursday November 30, 2023 @12:36PM (#38476342)
Thanks, I didn't know about `-t`, I'll read up on it.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by kzrdude on Thursday November 30, 2023 @12:09PM (#38475969)
-t is useful but -g doesn't require lookup in help first. Maybe the worse is better principle?
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ... by 3PS on Thursday November 30, 2023 @12:16PM (#38476058)
Tbh I've always just typed -t followed by something that feels intuitive and it's always worked. Never really bothered looking in help until I made the above comment.