Use rg if it's present in bin/replace

I like this `bin/replace` script, but I've recently switched from `ag`
to [ripgrep](https://github.com/BurntSushi/ripgrep). This checks for the
presence of `rg` and uses it in `bin/replace`, passing the correct
parameter to disable colors.
This commit is contained in:
Ian C. Anderson 2018-11-29 16:13:13 -05:00 committed by Geoff Harcourt
parent 013f9711af
commit b132c644be

View file

@ -9,7 +9,12 @@ shift
replace_with="$1"
shift
items=$(ag -l --nocolor "$find_this" "$@")
if which rg &>/dev/null ; then
items=$(rg -l --color never "$find_this" "$@")
else
items=$(ag -l --nocolor "$find_this" "$@")
fi
temp="${TMPDIR:-/tmp}/replace_temp_file.$$"
IFS=$'\n'
for item in $items; do