make Replace work with both regex/nonregex, auto fix js/ts/tsx
This commit is contained in:
parent
ce0558a53f
commit
5442fdbb76
@ -93,3 +93,4 @@ name = "lang#swift"
|
||||
|
||||
[[layers]]
|
||||
name = "format"
|
||||
format_on_save = true
|
||||
|
@ -107,6 +107,7 @@ function Replace () {
|
||||
-s Source pattern
|
||||
-d Destination pattern
|
||||
-r Remove line
|
||||
--regex Match pattern with regex
|
||||
--seperator= Seperator, # by default
|
||||
-h Display this message"
|
||||
}
|
||||
@ -116,6 +117,7 @@ function Replace () {
|
||||
SEP=";"
|
||||
DEBUG=false
|
||||
REMOVE=false
|
||||
REGEX=false
|
||||
while getopts ":rhf:s:d:-:" opt
|
||||
do
|
||||
case "${opt}" in
|
||||
@ -125,6 +127,9 @@ function Replace () {
|
||||
debug)
|
||||
DEBUG=true
|
||||
;;
|
||||
regex)
|
||||
REGEX=true
|
||||
;;
|
||||
seperator=*)
|
||||
val=${OPTARG#*=}
|
||||
SEP=$val
|
||||
@ -142,8 +147,9 @@ function Replace () {
|
||||
usage; return 1 ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND-1))
|
||||
MATCHED_FILES=`ag -Q $SRC -l -G $FILE_REGEX`
|
||||
SEARCH_CMD="ag `$REGEX || echo -Q` \"$SRC\" -l -G \"$FILE_REGEX\""
|
||||
MATCHED_FILES=`eval "$SEARCH_CMD"`
|
||||
echo "Replace in current files:$fg[green]\n$MATCHED_FILES$reset_color"
|
||||
if $REMOVE; then
|
||||
SED_CMD=\\${SEP}$SRC${SEP}d
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user