diff --git a/SpaceVim.d/init.toml b/SpaceVim.d/init.toml index 296542e..a86bafd 100644 --- a/SpaceVim.d/init.toml +++ b/SpaceVim.d/init.toml @@ -93,3 +93,4 @@ name = "lang#swift" [[layers]] name = "format" +format_on_save = true diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 74f6d90..023d3a0 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -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