If you spend a lot of time on the command line, you’ve probably leaned on grep more times than you can count. I certainly have—often with a well-tuned alias and a handful of flags to make it usable. But somehow, it took me until recently to come across ripgrep , and I honestly can’t believe it. It’s faster, smarter, and far more powerful than regular grep—even with a custom alias.

Here are some of my favorite rg tricks so far:


1) Context and Count Options

It’s not just about finding a match—it’s about seeing where and how many.

# Show count of matches and include 2 lines of context around each
rg --count --context 2 "foo" .

# Or specify explicit before/after context
rg -B 3 -A 2 "foo" .

2) Searching Compressed Files

rg can dive into compressed files seamlessly with -z.

# Search for "foo" inside a gzipped file
rg "foo" -z bar.gz

3) Adding Colors (great as an alias)

Custom coloring makes important matches pop off the screen.

rg 'ALERT' \
  --colors 'path:fg:red' --colors 'path:bg:white' \
  --colors 'match:fg:blue' \
  --colors 'line:bg:yellow' \
  --colors 'match:style:bold' \
  -z messages-2022-04-2*.gz

Conclusion

ripgrep feels like the tool I should have been using all along. It’s blazingly fast, efficient, and flexible—everything I wanted grep to be but never quite was. It’s one of those utilities that, once discovered, you can’t imagine working without.