terminal-life:~$

ripgrep — grep, but it respects you

The search command that skips your node_modules without being asked, colors its output, and still beats plain grep in a footrace.

Ripgrep (rg) recursively searches files for a regex, like grep -r — except it automatically ignores whatever your .gitignore ignores, skips hidden files and binary blobs, parallelizes across cores, and prints results in color with the matching text highlighted. In practice that means the two most common grep rituals — remembering the right flag combination and waiting while it chews through thousands of vendored files you never wanted — both disappear. The regex engine (Rust’s) isn’t backtracking-based, so pathological patterns can’t hang it. And when you do want to search the ignored files, one flag gets you there instead of a fight.

//install

# macOS
brew install ripgrep
# Debian/Ubuntu (18.04+)
sudo apt install ripgrep
# Fedora
sudo dnf install ripgrep
# Arch
sudo pacman -S ripgrep

//examples

# Find every TODO in the repo (gitignored dirs skipped)
rg TODO

# Case-insensitive search, only Python files, show line numbers
rg -i -n --type py 'def handle_'

# Search ALL files, even gitignored ones (node_modules included)
rg -uu 'secret_key'

# Show 3 lines of context around each match
rg -C 3 'connection refused' /var/log

# List files containing a match instead of the lines
rg --files-with-matches 'deprecated' | xargs nvim

# Count matches per file, sorted
rg -c 'error' logs/ | sort -t: -k2 -rn

//pro tip

rg --type list shows every file type rg knows — then filter with -t <type>. The types compose knowledge you’d otherwise express as fragile glob patterns: -t js covers .js, .mjs, .cjs, and .jsx without you enumerating any of them.

//honest limits

Ripgrep deliberately ignores hidden and ignored files by default, so “it found nothing” usually means “look in .gitignore” — -uu lifts the filters. It’s a search tool, not a stream filter: in a pipe (cat x | grep y) plain grep or sed is still the right tool. And if you’re writing scripts for tiny minimal containers, note that rg isn’t part of POSIX tooling — grep is always there; rg is something you install.