zsh: Use $+commands[] instead of command -v
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
emulate -L zsh -o extendedglob
|
||||
|
||||
# Return if fzf is not available
|
||||
if ! command -v fzf &>/dev/null; then
|
||||
if (( ! $+commands[fzf] )); then
|
||||
printf "command not found: fzf" >&2
|
||||
return 1
|
||||
fi
|
||||
@@ -56,9 +56,8 @@ read -r -d '' <<EOT
|
||||
git show "${(j:%n:)format}" "$date" --color=always --patch-with-stat "\$out"
|
||||
EOT
|
||||
fzf_preview[patch]="$fzf_preview[construct] { $REPLY"
|
||||
if command -v diff-so-fancy &>/dev/null; then
|
||||
(( ! $+commands[diff-so-fancy] )) ||
|
||||
fzf_preview[patch]+=" | diff-so-fancy --color=always"
|
||||
fi
|
||||
fzf_preview[patch]+=" }"
|
||||
|
||||
read -r -d '' <<EOT
|
||||
@@ -69,9 +68,9 @@ fzf_preview[stat]="$fzf_preview[construct] { $REPLY }"
|
||||
# Put the commit hash into the clipboard
|
||||
# (If no known clipboard tool is available, just print it)
|
||||
local fzf_copy_command="$fzf_preview[construct] echo -n \"\$out\""
|
||||
if [[ $OSTYPE =~ darwin ]] && command -v pbcopy &>/dev/null; then
|
||||
if [[ $OSTYPE =~ darwin ]] && (( $+commands[pbcopy] )); then
|
||||
fzf_copy_command+=" | pbcopy"
|
||||
elif command -v xclip &>/dev/null; then
|
||||
elif (( $+commands[xclip] )); then
|
||||
fzf_copy_command+=" | xclip -selection c"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user