On , I learnt ...
You can define custom file-type filters in ripgrep
ripgrep
lets you filter files by
their language type — e.g. search only C
-related files:
rg 'int main' --type c
Here the --type
value maps to a glob (e.g. c
maps to *.{c.h}
). You can
list all the available types with rg --type-list
.
Furthermore you can define your own types such as “web” related files:
rg --type-add 'web:*.{html,css,js}'
which lets you search such files with:
rg --type=web $QUERY
Even better, define your own types in your $RIPGREP_CONFIG_PATH
config file:
# ~/.ripgreprc
--smart-case
--hidden
--glob=!git/*
--type-add=web:*.{html,css,js}
--type-add=django:*.{py,html}