zsh: Improve how command availability is detected

This commit is contained in:
2025-09-11 01:46:54 +02:00
parent ba282e656d
commit 254bfd4be2

View File

@@ -60,12 +60,12 @@ export EDITOR=nvim
alias cl="clear" alias cl="clear"
if hash bat 2>/dev/null; then if (( $+commands[hash] )); then
export BAT_THEME="gruvbox-dark" export BAT_THEME="gruvbox-dark"
alias cat=bat alias cat=bat
fi fi
if hash devcontainer 2>/dev/null; then if (( $+commands[devcontainer] )); then
dc() { dc() {
ORIG_DIR="$PWD" ORIG_DIR="$PWD"
while [[ "$PWD" != / ]] ; do while [[ "$PWD" != / ]] ; do
@@ -92,7 +92,7 @@ if hash devcontainer 2>/dev/null; then
} }
fi fi
if hash pnpm 2>/dev/null; then if (( $+commands[pnpm] )); then
export PNPM_HOME="/home/tim/.local/share/pnpm" export PNPM_HOME="/home/tim/.local/share/pnpm"
case ":$PATH:" in case ":$PATH:" in
*":$PNPM_HOME:"*) ;; *":$PNPM_HOME:"*) ;;
@@ -110,14 +110,14 @@ export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
--prompt="> " --marker="◆" --pointer=">" --separator="─" --prompt="> " --marker="◆" --pointer=">" --separator="─"
--scrollbar="│" --info="right"' --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_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
fi fi
if hash fzf 2>/dev/null; then if (( $+commands[fzf] )); then
source <(fzf --zsh) source <(fzf --zsh)
if hash paru 2>/dev/null; then if (( $+commands[paru] )); then
function pi { function pi {
paru -Slq | fzf -q "$1" --border-label="Packages" --multi --preview 'paru -Si {1} --color=always' | xargs -ro paru -S 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 fi
export _ZO_FZF_OPTS="--tmux" export _ZO_FZF_OPTS="--tmux"
if hash zoxide 2>/dev/null; then if (( $+commands[zoxide] )); then
eval "$(zoxide init zsh --cmd cd)" eval "$(zoxide init zsh --cmd cd)"
fi fi