mirror of
https://github.com/IlanCosman/tide.git
synced 2024-08-17 04:00:22 +03:00
Replace --regex with -r, it's used often enough
This commit is contained in:
parent
0d524360ac
commit
6047c86351
@ -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
|
||||
|
@ -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|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
|
||||
(0|(?<dirty>.*))\n(0|(?<untracked>.*))(\n(0|(?<behind>.*))\t(0|(?<ahead>.*)))?' \
|
||||
"$(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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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." \
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user