From 6047c8635103cf022445f1372996a8478997ed7d Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Sun, 31 Oct 2021 13:44:16 -0700 Subject: [PATCH] Replace --regex with -r, it's used often enough --- conf.d/_tide_init.fish | 4 ++-- functions/_tide_item_git.fish | 10 +++++----- functions/_tide_item_go.fish | 2 +- functions/_tide_item_kubectl.fish | 2 +- functions/_tide_item_php.fish | 2 +- functions/_tide_sub_bug-report.fish | 18 +++++++++--------- .../tide/configure/choices/all/finish.fish | 2 +- .../tide/configure/choices/all/style.fish | 2 +- .../choices/classic/classic_prompt_color.fish | 2 +- tests/test_setup.fish | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/conf.d/_tide_init.fish b/conf.d/_tide_init.fish index c4ae713..0ebbb80 100644 --- a/conf.d/_tide_init.fish +++ b/conf.d/_tide_init.fish @@ -5,7 +5,7 @@ function _tide_init_install --on-event _tide_init_install source (functions --details _tide_sub_configure) _load_config lean _tide_finish - set -a _tide_var_list (set --names | string match --regex "^tide.*") + set -a _tide_var_list (set --names | string match -r "^tide.*") status is-interactive && switch (read --prompt-str="Configure tide prompt? [Y/n] " | string lower) case y ye yes '' @@ -48,5 +48,5 @@ end function _tide_init_uninstall --on-event _tide_init_uninstall set -e $_tide_var_list _tide_var_list $_tide_prompt_var - functions --erase (functions --all | string match --entire --regex '^_tide_') + functions --erase (functions --all | string match --entire -r '^_tide_') end diff --git a/functions/_tide_item_git.fish b/functions/_tide_item_git.fish index c7b2ae3..f834c50 100644 --- a/functions/_tide_item_git.fish +++ b/functions/_tide_item_git.fish @@ -37,16 +37,16 @@ function _tide_item_git end # Git status/stash + Upstream behind/ahead - test "$inside_git_dir" = true && set -l _set_dir_opt -C $git_dir/.. + test $inside_git_dir = true && set -l _set_dir_opt -C $git_dir/.. # Suppress errors in case we are in a bare repo or there is no upstream git_info=(git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null) \ string match -qr '(0|(?.*))\n(0|(?.*))\n(0|(?.*)) (0|(?.*))\n(0|(?.*))(\n(0|(?.*))\t(0|(?.*)))?' \ "$(git $_set_dir_opt stash list 2>/dev/null | count - string match --regex ^UU $git_info | count - string match --regex ^[ADMR]. $git_info | count - string match --regex ^.[ADMR] $git_info | count - string match --regex '^\?\?' $git_info | count + string match -r ^UU $git_info | count + string match -r ^[ADMR]. $git_info | count + string match -r ^.[ADMR] $git_info | count + string match -r '^\?\?' $git_info | count git rev-list --count --left-right @{upstream}...HEAD 2>/dev/null)" if test -n "$operation$conflicted" diff --git a/functions/_tide_item_go.fish b/functions/_tide_item_go.fish index 2138a2b..304acc5 100644 --- a/functions/_tide_item_go.fish +++ b/functions/_tide_item_go.fish @@ -1,3 +1,3 @@ function _tide_item_go - test -e go.mod && _tide_print_item go $tide_go_icon' ' (go version | string match --regex "[\d.]+") + test -e go.mod && _tide_print_item go $tide_go_icon' ' (go version | string match -r "[\d.]+") end diff --git a/functions/_tide_item_kubectl.fish b/functions/_tide_item_kubectl.fish index 42ae13b..ab044b3 100644 --- a/functions/_tide_item_kubectl.fish +++ b/functions/_tide_item_kubectl.fish @@ -1,4 +1,4 @@ function _tide_item_kubectl kubectl config view --minify --output 'jsonpath={.current-context}/{..namespace}' 2>/dev/null | read -l context && - _tide_print_item kubectl $tide_kubectl_icon' ' (string replace --regex '/(|default)$' '' $context) + _tide_print_item kubectl $tide_kubectl_icon' ' (string replace -r '/(|default)$' '' $context) end diff --git a/functions/_tide_item_php.fish b/functions/_tide_item_php.fish index 3aad466..64fc59b 100644 --- a/functions/_tide_item_php.fish +++ b/functions/_tide_item_php.fish @@ -1,3 +1,3 @@ function _tide_item_php - test -e composer.json && _tide_print_item php $tide_php_icon' ' (php --version | string match --regex 'PHP ([\d.]+)')[2] + test -e composer.json && _tide_print_item php $tide_php_icon' ' (php --version | string match -r 'PHP ([\d.]+)')[2] end diff --git a/functions/_tide_sub_bug-report.fish b/functions/_tide_sub_bug-report.fish index f3360e4..ab82aac 100644 --- a/functions/_tide_sub_bug-report.fish +++ b/functions/_tide_sub_bug-report.fish @@ -6,17 +6,17 @@ function _tide_sub_bug-report https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install ilancosman/tide@v5" else if set -q _flag_verbose - set --long | string match --regex "^_?tide.*" | # Get only tide variables - string match --regex --invert "^_tide_prompt_var.*" | # Remove _tide_prompt_var - string match --regex --invert "^_tide_var_list.*" # Remove _tide_var_list + set --long | string match -r "^_?tide.*" | # Get only tide variables + string match -r --invert "^_tide_prompt_var.*" | # Remove _tide_prompt_var + string match -r --invert "^_tide_var_list.*" # Remove _tide_var_list else - set -l fish_version (fish --version | string match --regex "fish, version (\d\.\d\.\d)")[2] + set -l fish_version (fish --version | string match -r "fish, version (\d\.\d\.\d)")[2] _tide_check_version Fish fish-shell/fish-shell "(\d\.\d\.\d)" $fish_version || return - set -l tide_version (tide --version | string match --regex "tide, version (\d\.\d\.\d)")[2] + set -l tide_version (tide --version | string match -r "tide, version (\d\.\d\.\d)")[2] _tide_check_version Tide IlanCosman/tide "v(\d\.\d\.\d)" $tide_version || return - test (git --version | string match --regex "git version ([\d\.]*)" | string replace --all . '')[2] -gt 2220 + test (git --version | string match -r "git version ([\d\.]*)" | string replace --all . '')[2] -gt 2220 _tide_check_condition \ "Your git version is too old." \ "Tide requires at least version 2.22." \ @@ -29,7 +29,7 @@ function _tide_sub_bug-report "Please uninstall it before submitting a bug report." || return set -l fish_startup_time (fish -ic "time fish -c exit" 2>&1 | - string match --regex "Executed in(.*)fish" | string trim)[2] + string match -r "Executed in(.*)fish" | string trim)[2] read --local --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os read --local --prompt-str "What terminal emulator are you using? (e.g Kitty): " terminal_emulator @@ -47,10 +47,10 @@ end function _tide_check_version -a program_name repo_name regex_to_get_version current_version curl --silent https://github.com/$repo_name/releases/latest | - string match --regex ".*$repo_name/releases/tag/$regex_to_get_version.*" | + string match -r ".*$repo_name/releases/tag/$regex_to_get_version.*" | read --local --line __ latestVersion - string match --quiet --regex "^$latestVersion" "$current_version" + string match --quiet -r "^$latestVersion" "$current_version" _tide_check_condition \ "Your $program_name version is out of date." \ "The latest is $latestVersion. You have $current_version." \ diff --git a/functions/tide/configure/choices/all/finish.fish b/functions/tide/configure/choices/all/finish.fish index 66cab66..c6c48e9 100644 --- a/functions/tide/configure/choices/all/finish.fish +++ b/functions/tide/configure/choices/all/finish.fish @@ -31,7 +31,7 @@ function _tide_finish end # Set the real variables - for fakeVar in (set --names | string match --regex "^fake_tide.*") + for fakeVar in (set --names | string match -r "^fake_tide.*") set -U (string replace 'fake_' '' $fakeVar) $$fakeVar end diff --git a/functions/tide/configure/choices/all/style.fish b/functions/tide/configure/choices/all/style.fish index 61542ba..ff3d5d2 100644 --- a/functions/tide/configure/choices/all/style.fish +++ b/functions/tide/configure/choices/all/style.fish @@ -29,5 +29,5 @@ function style end function _load_config -a name - string replace --regex '^' 'set -g fake_' <(status dirname)/../../configs/$name.fish | source + string replace -r '^' 'set -g fake_' <(status dirname)/../../configs/$name.fish | source end diff --git a/functions/tide/configure/choices/classic/classic_prompt_color.fish b/functions/tide/configure/choices/classic/classic_prompt_color.fish index 33b13c0..2189f36 100644 --- a/functions/tide/configure/choices/classic/classic_prompt_color.fish +++ b/functions/tide/configure/choices/classic/classic_prompt_color.fish @@ -32,7 +32,7 @@ function classic_prompt_color end function _set_all_items_bg_color -a color - for var in (set --names | string match --regex "fake_.*_bg_color.*") + for var in (set --names | string match -r "fake_.*_bg_color.*") set $var $color end end diff --git a/tests/test_setup.fish b/tests/test_setup.fish index a7f5de8..c359a92 100644 --- a/tests/test_setup.fish +++ b/tests/test_setup.fish @@ -1,5 +1,5 @@ function _tide_decolor - string replace --all --regex '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$argv" + string replace --all -r '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$argv" end funcsave _tide_decolor