Options I use with rg (ripgrep)
ripgrep (rg) has long replaced the standard UNIX grep command for me. My main usage is rg sometext, but there are a few flags I sometimes reach for.
Limit matches to specific file types
For example:
rg --type csv sometext
rg --type log sometext
Use --typelist to see the list of supported types. You can add more types according to man rg.
Not ignoring files
I have a lengthy ~/.gitignore file which rg honours by default, but --no-ignore ignores the ignores.
The shorthand is -u (“unrestricted”) and -uu to also not ignore hidden files.
An “and” search with colour
To match two expressions, highlighting both matches rather than just the last expression:
rg --color always foo | rg baz
Setting default configuration
My .zshrc contains:
export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc
And that ripgreprc file contains one argument per line:
--color
always