From 733da1729205f2bab5bbe17c54fcf325f037270b Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 6 Nov 2020 01:24:31 +0800 Subject: [PATCH] [feature] bulk replace --- bin/br | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 bin/br diff --git a/bin/br b/bin/br new file mode 100755 index 0000000..6d9ed73 --- /dev/null +++ b/bin/br @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$#" -lt 2 ]; then + echo "Usage: $0 " + 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