Last week I searched a 400,000-line monorepo for a function name and had the results before my finger was off the Enter key. That is the everyday case for ripgrep: a drop-in replacement for grep that is dramatically faster, ignores everything in your .gitignore by default, and gets recursive source-code search right without a pile of flags.
Installing ripgrep
macOS
brew install ripgrep
rg --version
Linux
Debian 12 and Ubuntu 22.04 onwards package it directly, and the binary is called rg, not ripgrep:
sudo apt update && sudo apt install ripgrep
Distro packages lag the upstream release by a fair margin. If you want current features, grab the .deb from the GitHub releases page, or install with cargo install ripgrep if you already have a Rust toolchain. There are no runtime dependencies either way — it is a single static-ish binary.
The flags that actually matter
ripgrep has a long manual and you need about eight flags from it. These are the ones I use daily:
-icase-insensitive, and-Ssmart-case: lower-case pattern matches anything, a capital makes it case-sensitive.-wwhole word. Stopsidmatchinguuid,validandidentity.-Ffixed string. Use it whenever the pattern contains brackets, dots or dollar signs and you do not want regex semantics.-t py/-T testsearch only, or never, a file type.rg --type-listshows the lot.-g '!vendor/'glob include or exclude, repeatable.-lfilenames only,-ccounts per file,-ojust the matching text.-C 3three lines of context either side.--hiddenand-uuwhen you deliberately want dotfiles and ignored files back in scope.
That last one is the flag people miss. ripgrep skipping ignored files is the single biggest reason it feels fast, but it also means a file really can be there and not be found. -u unignores, -uu adds hidden files, -uuu adds binaries — roughly plain grep -r behaviour.
A real codebase search
The job that comes up constantly: you are deleting a deprecated function and need every call site, without the test fixtures and the vendored dependencies drowning the output.
# every call site, production code only
rg -w -t py 'get_user_by_id' -g '!tests/' -g '!migrations/'
# just the files, to feed into an editor or a script
rg -l -w 'get_user_by_id' -g '!tests/'
# how bad is it, per file?
rg -c -w 'get_user_by_id' | sort -t: -k2 -rn | head
For log filtering, the same tool works on a stream. ripgrep reads stdin happily, and --passthru is the trick worth knowing — it prints every line but highlights the matches, which is far easier to read than a filtered-down wall of text when you are trying to follow a request through a log.
journalctl -u nginx --since '1 hour ago' | rg --passthru '5\d\d'
rg -N -e 'timeout' -e 'refused' /var/log/app/*.log
One more that saves real time: -r previews a replacement without touching anything on disk. Check the output, then run the actual edit with sed once you are happy.
rg 'api_v1' -r 'api_v2' # preview only
rg -l 'api_v1' | xargs sed -i 's/api_v1/api_v2/g'
Shell integration and a config file
ripgrep will read a config file, but only if you tell it where one is. Put this in your .zshrc or .bashrc:
export RIPGREP_CONFIG_PATH="$HOME/.config/ripgrep/config"
alias rgh='rg --hidden --no-ignore'
And in that config file, one flag per line, no quoting:
--smart-case
--max-columns=200
--max-columns-preview
--glob=!.git/*
In Vim, set grepprg=rg\ --vimgrep\ --smart-case makes :grep usable again. VS Code already uses ripgrep internally for its search panel, so you are running it whether you knew it or not. If you are doing this all day in a stock terminal, it is worth pairing with a faster emulator too — I went through the options in the best terminal emulators for developers.
When grep is still the right call
- Anything you ship. grep is POSIX and present on every box; ripgrep is a thing you installed. Shell scripts that run on servers you do not control should use grep.
- Back-references and look-around. ripgrep uses Rust’s regex engine, which guarantees linear time by refusing to support them.
grep -Phas PCRE, and so doesrg -Pif it was built with that feature — but do not assume it is there. - One quick look inside one file.
grep foo file.txtis fine. The gains are in recursive tree searches. - Muscle memory under pressure. At 2am on an unfamiliar host, use what is already there.
The verdict
Install ripgrep, set --smart-case in the config file, and use it for every interactive search you do. Keep grep in your scripts. This is the cheapest upgrade on this list: one package, no configuration required, and searches that used to give you time to think now come back instantly.

Leave a Reply
You must be logged in to post a comment.