gripgrep is a small, themeable grep-like search tool written in Rust. The CLI
binary is grgr.
It recursively searches from the current directory, prints matching file paths, line numbers, match positions, and highlighted matching text when color output is supported by the terminal.
I'm doing a major rewrite of an Elixir project in Rust, and this is my "get used to Rust again" project. There's also some ricing involved in regards to my motivation for this tool, plus a bit of Omarchy influence :).
Also it is opinionated in that it only tries to match in text files, see for example:
Line 294 in 4313502
I'll keep extending this to fit my scripting needs.
Build from source:
cargo build --releaseRun the binary from the build output:
./target/release/grgr "needle"Or during development:
cargo run -- "needle"grgr [OPTIONS] [PATTERN] [SEARCH_PATH]PATTERN is a regular expression.
SEARCH_PATH is an optional file or directory to search. When omitted, grgr
searches the current directory.
Basic search from the current directory:
grgr "TODO"Search with a regular expression:
grgr "fn [a-z_]+"Search within a specific directory:
grgr "TODO" srcSearch a single file:
grgr "TODO" src/main.rsDisable color output:
grgr --no-color "needle"Print full long lines instead of abbreviated matches:
grgr --no-abbrev "needle"Respect local ignore files while searching:
grgr --respect-ignore "needle"By default, grgr searches files even when they are matched by .ignore or
.gitignore. --respect-ignore opts in to those project-local ignore files.
Global git ignores and .git/info/exclude are not used.
List built-in themes:
grgr --themes-listUse a built-in theme:
grgr --theme "tokyo night" "needle"Currently available themes:
- tokyo night
- catppuccin
- ethereal
- osaka jade
- kanagawa
- nord
- miasma
- hackerman
- everforest
- gruvbox
- retro 82
- ristretto
- lumon
- matte black
- vantablack
- solitude
- last horizon
- flexoki light
- rose pine dawn
- catppuccin latte
- white
Use custom ANSI color codes:
grgr --colors "38;5;75:38;5;009:38;5;141:38;5;214:38;5;15" "needle"The custom color fields are, in order:
path:line:position:matched-text:normal-text
Example:
./src/main.rs
72:10: #[command(version, about = "A grep like tool")]
For lines with multiple matches, all match positions are printed before the line contents:
./repeat.txt
1:1:5:9: abc abc abc
Positions are 1-based character positions.
Color output is automatically disabled when stdout is not a terminal, when
NO_COLOR is set, when TERM=dumb, or when the terminal does not advertise
256-color or true-color support.
Use --no-color to force plain output.