From 254bfd4be2c1cc86cae998d0a385ba1a75242000 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Thu, 11 Sep 2025 01:46:54 +0200 Subject: [PATCH] zsh: Improve how command availability is detected --- zsh/dot-zshrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc index 095ad17..6123720 100644 --- a/zsh/dot-zshrc +++ b/zsh/dot-zshrc @@ -60,12 +60,12 @@ export EDITOR=nvim alias cl="clear" -if hash bat 2>/dev/null; then +if (( $+commands[hash] )); then export BAT_THEME="gruvbox-dark" alias cat=bat fi -if hash devcontainer 2>/dev/null; then +if (( $+commands[devcontainer] )); then dc() { ORIG_DIR="$PWD" while [[ "$PWD" != / ]] ; do @@ -92,7 +92,7 @@ if hash devcontainer 2>/dev/null; then } fi -if hash pnpm 2>/dev/null; then +if (( $+commands[pnpm] )); then export PNPM_HOME="/home/tim/.local/share/pnpm" case ":$PATH:" in *":$PNPM_HOME:"*) ;; @@ -110,14 +110,14 @@ export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS' --prompt="> " --marker="◆" --pointer=">" --separator="─" --scrollbar="│" --info="right"' -if hash fd 2>/dev/null; then +if (( $+commands[fd] )); then export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" fi -if hash fzf 2>/dev/null; then +if (( $+commands[fzf] )); then source <(fzf --zsh) - if hash paru 2>/dev/null; then + if (( $+commands[paru] )); then function pi { paru -Slq | fzf -q "$1" --border-label="Packages" --multi --preview 'paru -Si {1} --color=always' | xargs -ro paru -S } @@ -125,7 +125,7 @@ if hash fzf 2>/dev/null; then fi export _ZO_FZF_OPTS="--tmux" -if hash zoxide 2>/dev/null; then +if (( $+commands[zoxide] )); then eval "$(zoxide init zsh --cmd cd)" fi