Rename temporary probe helper to avoid function collisions

Co-authored-by: robbyrussell <257+robbyrussell@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-06 15:50:21 +00:00
committed by GitHub
co-authored by robbyrussell
parent ded814e0ac
commit e1d7934216
+12 -12
View File
@@ -20,9 +20,9 @@ __omz_probe_cache="$ZSH_CACHE_DIR/appearance-probes"
__omz_probe_cached=("$__omz_probe_cache"(Nm-1)) __omz_probe_cached=("$__omz_probe_cache"(Nm-1))
[[ -z "$__omz_probe_cached" ]] || source "$__omz_probe_cache" [[ -z "$__omz_probe_cached" ]] || source "$__omz_probe_cache"
function test-cmd-args { function __omz_test_cmd_args {
# Usage: test-cmd-args cmd args... # Usage: __omz_test_cmd_args cmd args...
# e.g. test-cmd-args gls --color # e.g. __omz_test_cmd_args gls --color
# Runs `cmd args... /dev/null` and remembers whether it succeeded # Runs `cmd args... /dev/null` and remembers whether it succeeded
local key="$*" local key="$*"
if (( ! ${+__omz_probes[$key]} )); then if (( ! ${+__omz_probes[$key]} )); then
@@ -36,7 +36,7 @@ function test-cmd-args {
} }
# Use diff --color if available # Use diff --color if available
if test-cmd-args diff --color /dev/null; then if __omz_test_cmd_args diff --color /dev/null; then
function diff { function diff {
command diff --color "$@" command diff --color "$@"
} }
@@ -69,34 +69,34 @@ fi
netbsd*) netbsd*)
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors); # On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
test-cmd-args gls --color && alias ls='gls --color=tty' __omz_test_cmd_args gls --color && alias ls='gls --color=tty'
;; ;;
openbsd*) openbsd*)
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base, # On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
# with color and multibyte support) are available from ports. # with color and multibyte support) are available from ports.
# `colorls` will be installed on purpose and can't be pulled in by installing # `colorls` will be installed on purpose and can't be pulled in by installing
# coreutils (which might be installed for ), so prefer it to `gls`. # coreutils (which might be installed for ), so prefer it to `gls`.
test-cmd-args gls --color && alias ls='gls --color=tty' __omz_test_cmd_args gls --color && alias ls='gls --color=tty'
test-cmd-args colorls -G && alias ls='colorls -G' __omz_test_cmd_args colorls -G && alias ls='colorls -G'
;; ;;
(darwin|freebsd)*) (darwin|freebsd)*)
# This alias works by default just using $LSCOLORS # This alias works by default just using $LSCOLORS
test-cmd-args ls -G && alias ls='ls -G' __omz_test_cmd_args ls -G && alias ls='ls -G'
# Only use GNU ls if installed and there are user defaults for $LS_COLORS, # Only use GNU ls if installed and there are user defaults for $LS_COLORS,
# as the default coloring scheme is not very pretty # as the default coloring scheme is not very pretty
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \ zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
&& test-cmd-args gls --color \ && __omz_test_cmd_args gls --color \
&& alias ls='gls --color=tty' && alias ls='gls --color=tty'
;; ;;
*) *)
if test-cmd-args ls --color; then if __omz_test_cmd_args ls --color; then
alias ls='ls --color=tty' alias ls='ls --color=tty'
elif test-cmd-args ls -G; then elif __omz_test_cmd_args ls -G; then
alias ls='ls -G' alias ls='ls -G'
fi fi
;; ;;
esac esac
} }
unfunction test-cmd-args unfunction __omz_test_cmd_args
unset __omz_probes __omz_probe_cache __omz_probe_cached unset __omz_probes __omz_probe_cache __omz_probe_cached