[feature] bulk replace

This commit is contained in:
Klesh Wong 2020-11-06 01:24:31 +08:00
parent a980991fdc
commit 733da17292

21
bin/br Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <target> <replacement>"
exit 1
fi
REDFG=$(printf '\033[31m')
BLUBG=$(printf '\033[42m')
ag --color "$1" . | sed -E "s/$1/\\0$REDFG$BLUBG$2/g"
echo Are they ok for you?
read -r YN
case "$YN" in
y|Y)
ag "$1" . -l -0 | xargs -0 sed -Ei "s/$1/$2/g"
;;
*)
exit
;;
esac