Ripgrep: Difference between revisions
From wikinotes
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
|- | |- | ||
| official docs || https://github.com/BurntSushi/ripgrep | | official docs || https://github.com/BurntSushi/ripgrep | ||
|- | |||
| configuration docs || https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file | |||
|- | |- | ||
|} | |} | ||
Line 18: | Line 20: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| <code>${ANYWHERE}/.ripgreprc</code> || | | <code>RIPGREP_CONFIG_PATH=${ANYWHERE}/.ripgreprc</code> || optional config file | ||
|- | |- | ||
| <code>${ANYWHERE}/.rgignore</code> || subdirectory specific ignore files | | <code>${ANYWHERE}/.rgignore</code> || subdirectory specific ignore files | ||
Line 59: | Line 61: | ||
This is not read automatically, you must point to it with the envvar <code>$RIPGREP_CONFIG_PATH</code>. | This is not read automatically, you must point to it with the envvar <code>$RIPGREP_CONFIG_PATH</code>. | ||
example | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# | # ./.ripgreprc | ||
--sortr | |||
path | |||
-- | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- .ripgreprc --> | </blockquote><!-- .ripgreprc --> | ||
</blockquote><!-- Configuration --> | </blockquote><!-- Configuration --> |
Latest revision as of 18:16, 19 June 2022
A faster alternative to grep.
Can also perform search/replace.
ripgrep is restricted to single-lines, and does not support lookahead/lookbehind.
If you need these features checkout universal code grep or silversearcher.
Documentation
official docs https://github.com/BurntSushi/ripgrep configuration docs https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file
Locations
RIPGREP_CONFIG_PATH=${ANYWHERE}/.ripgreprc
optional config file ${ANYWHERE}/.rgignore
subdirectory specific ignore files
Tutorials
learnbyexample (cookbook) https://learnbyexample.github.io/substitution-with-ripgrep/
Usage
rg --pretty search | less -Ri # pipe rg to less rg -g '*.md' search # search files matching '*.md' for text 'email' rg -g '!*/test/*' search # exclude paths matching */test/* (-g can be used multiple times) rg -i search # case insensitive search rg -uuu search # ignore .gitignore, .ignore, ... # search files from rg rg 'search' $(rg -l other_search) # search files from `find` find . -type f -path '*/mutations/*.rb' -print0 \ | xargs -0 rg 'search'
Configuration
.ripgreprc
Any arguments you'd like to always be passed to ripgrep, dump in a ripgreprc.
This is not read automatically, you must point to it with the envvar$RIPGREP_CONFIG_PATH
.example
# ./.ripgreprc --sortr path