Update __z to latest version

This commit is contained in:
Tim 2025-05-22 01:48:47 +02:00
parent fb42de7375
commit ee26ef56ef

View File

@ -14,7 +14,7 @@ function __z -d "Jump to a recent directory."
function __z_legacy_escape_regex function __z_legacy_escape_regex
# taken from escape_string_pcre2 in fish # taken from escape_string_pcre2 in fish
# used to provide compatibility with fish 2 # used to provide compatibility with fish 2
for c in (string split '' $argv) for c in (string split -- '' $argv)
if contains $c (string split '' '.^$*+()?[{}\\|-]') if contains $c (string split '' '.^$*+()?[{}\\|-]')
printf \\ printf \\
end end
@ -123,15 +123,15 @@ function __z -d "Jump to a recent directory."
for arg in $argv for arg in $argv
set -l escaped $arg set -l escaped $arg
if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available
set escaped (string escape --style=regex $escaped) set escaped (string escape --style=regex -- $escaped)
else else
set escaped (__z_legacy_escape_regex $escaped) set escaped (__z_legacy_escape_regex $escaped)
end end
# Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32 # Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32
set escaped (string replace --all \\ \\\\ $escaped) set escaped (string replace --all -- \\ \\\\ $escaped)
set qs $qs $escaped set qs $qs $escaped
end end
set -l q (string join '.*' $qs) set -l q (string join -- '.*' $qs)
if set -q _flag_list if set -q _flag_list
# Handle list separately as it can print common path information to stderr # Handle list separately as it can print common path information to stderr