diff --git a/zsh/containers.zsh b/zsh/containers.zsh index 87365fd..5edf539 100644 --- a/zsh/containers.zsh +++ b/zsh/containers.zsh @@ -32,5 +32,5 @@ fi if command-exists orb; then alias oc="orb" - setup-completions orb "$(command -v orb)" orb completion zsh + setup-completions orb "$(command-path orb)" orb completion zsh fi diff --git a/zsh/git.zsh b/zsh/git.zsh index 781b98e..894fe0d 100644 --- a/zsh/git.zsh +++ b/zsh/git.zsh @@ -10,7 +10,7 @@ git-largest-objects() { sed -n 's/^blob //p' | sort --numeric-sort --key=2 | cut -c 1-12,41- | - $(command -v gnumfmt || echo numfmt) \ + $(command-path gnumfmt || echo numfmt) \ --field=2 \ --to=iec-i \ --suffix=B \ diff --git a/zsh/kubernetes.zsh b/zsh/kubernetes.zsh index af9b922..1427596 100644 --- a/zsh/kubernetes.zsh +++ b/zsh/kubernetes.zsh @@ -9,7 +9,7 @@ alias hl="helm" alias mk="minikube" if command-exists kubectl; then - setup-completions kubectl "$(command -v kubectl)" kubectl completion zsh + setup-completions kubectl "$(command-path kubectl)" kubectl completion zsh export KREW_ROOT="$HOME/.krew" path_append "${KREW_ROOT}/bin" diff --git a/zsh/rust.zsh b/zsh/rust.zsh index 9d24a67..e2211bc 100644 --- a/zsh/rust.zsh +++ b/zsh/rust.zsh @@ -22,10 +22,10 @@ fi # ============================================================================== if command-exists rustup; then - setup-completions rustup "$(command -v rustup)" rustup completions zsh + setup-completions rustup "$(command-path rustup)" rustup completions zsh if command-exists cargo; then - setup-completions cargo "$(command -v cargo)" rustup completions zsh cargo + setup-completions cargo "$(command-path cargo)" rustup completions zsh cargo fi fi diff --git a/zsh/zoxide.zsh b/zsh/zoxide.zsh index 70b9bde..bf68c3a 100644 --- a/zsh/zoxide.zsh +++ b/zsh/zoxide.zsh @@ -3,7 +3,7 @@ # if command-exists zoxide; then - cached-eval "$(command -v zoxide)" zoxide init --cmd zox zsh + cached-eval "$(command-path zoxide)" zoxide init --cmd zox zsh # Use functions to allow regular zsh completion for cd to work. cd() { __zoxide_z "$@"; } diff --git a/zsh/zshrc.funcs.zsh b/zsh/zshrc.funcs.zsh index 5e39128..9f0cc88 100644 --- a/zsh/zshrc.funcs.zsh +++ b/zsh/zshrc.funcs.zsh @@ -47,7 +47,7 @@ setup-completions() { return 1 fi - if [[ -z "$(command -v "$cmd")" ]]; then + if [[ -z "$(command-path "$cmd")" ]]; then echo "setup-completions: Command not found: $cmd" >&2 return 1 fi diff --git a/zshenv b/zshenv index 8954464..ff69414 100644 --- a/zshenv +++ b/zshenv @@ -68,6 +68,10 @@ command-exists() { return $? } +command-path() { + echo "${commands[$1]}" +} + source-if-exists() { if [ -f "$1" ]; then source "$1" @@ -107,7 +111,7 @@ cached-eval() { return 1 fi - local md5_cmd="$(command -v md5 || command -v md5sum)" + local md5_cmd="$(command-path md5 || command-path md5sum)" local cache_hash="$(echo -n "${source_file}:${script}" | "$md5_cmd" | awk '{print $1}')" local cache_file="${cache_dir}/${cache_hash}.cache.zsh" diff --git a/zshrc b/zshrc index d5f7748..2b9b59c 100644 --- a/zshrc +++ b/zshrc @@ -148,7 +148,7 @@ if command-exists fzf; then export FZF_TMUX_OPTS="-p 75%" export FZF_TMUX_HEIGHT="" - cached-eval "$(command -v fzf)" fzf --zsh + cached-eval "$(command-path fzf)" fzf --zsh zstyle ':completion:*' menu no zstyle ':completion:*' special-dirs true @@ -224,7 +224,7 @@ fi # If available, make sure to load direnv shell hook before mise. if command-exists direnv; then - cached-eval "$(command -v direnv)" direnv hook zsh + cached-eval "$(command-path direnv)" direnv hook zsh fi MISE_HOME="$HOME/.local/share/mise" @@ -253,8 +253,8 @@ if ! command-exists starship && [ -f "$MISE_INSTALL_PATH" ]; then fi if command-exists starship; then - setup-completions starship "$(command -v starship)" starship completions zsh - cached-eval "$(command -v starship)" starship init zsh --print-full-init + setup-completions starship "$(command-path starship)" starship completions zsh + cached-eval "$(command-path starship)" starship init zsh --print-full-init else echo "WARN: starship not found, skipping prompt setup" >&2 echo " install with: mise install starship" >&2