LinuxMind trick — the one you will actually use today. Somewhere in this tree there is the function that sets that variable, and you need to see it right now. So you reach for grep -r and then wait, and wait, while it greps your binaries, your logs and that one vendored dependency nobody remembers adding. There is a faster tool that skips the noise for you, and it is called ripgrep.
Meet ripgrep
ripgrep — you run it as rg — is a recursive search tool written in Rust. It is the search engine behind a lot of modern editors, and it earns its keep for three reasons: it is genuinely fast, it respects your .gitignore so it never wades through what you already told it to ignore, and it skips binary files and hidden directories by default. It is grep -r with the common sense switched on.
If you ever wondered why the search bar in VS Code or Helix finds things instantly in a huge repository, rg is usually what is doing the work underneath.
Install it
# Debian / Ubuntu
sudo apt install ripgrep
# Fedora
sudo dnf install ripgrep
# Arch / CachyOS
sudo pacman -S ripgrep
The binary is simply rg. It is in every mainstream repository, so there is no reason to build it from source unless you are chasing the very latest release.
The basics, which are already an upgrade
rg TODO # every "TODO" in the tree
rg -i "api key" # case-insensitive
rg -w port # whole word only
rg -F "a.b(c)" # literal string, no regex
Run rg TODO in a project and watch the answer appear before your fingers leave the keys. No -r, no ., no directory argument: recursion and the current path are the default.
Narrow it down like a grown-up
rg -t py "def main" # only Python files
rg -t rust "unsafe" # only Rust files
rg -g "*.conf" listen # only files matching a glob
rg -g "!*test*" debug # everything except test files
The -t flag takes a language name and applies the right set of extensions, so -t py is smarter than --include=*.py. The -g glob works both ways: add a pattern to include, prefix it with ! to exclude. Chaining two or three of these is how you go from ten thousand hits to the four you wanted.
Show me the context
rg -l "setTimeout" # just the list of matching files
rg -c "import" # count matches per file
rg -A 3 "class Session" # three lines after each match
rg -B 2 -A 2 "return None" # two lines around each match
Context flags are what turn a search into understanding. -A and -B print lines after and before the hit, and -l collapses the output to a clean file list you can pipe straight into xargs. When a secret really is hiding in a dot-directory, --hidden lifts the ignore filter for that run — reach for it deliberately, because the whole point of the default is that it does not.
Today’s move
Replace the next grep -r you were about to type with rg, and add -t for the language you are in. That is the trick: same idea as grep, none of the walking through binaries and vendored code, and a syntax you will remember without a cheat sheet. Put alias grep='rg' in your shell config if you like living dangerously, or keep it as the tool you reach for by name. Either way, your next search will come back before you have finished blinking.





Leave a Reply