zsh: Use dictionary for command existence check

Use the `commands` dictionary from zsh instead of always calling
`command`.

Regex used:
s/command -v \([^ ]*\) &>\/dev\/null/(( $+commands[\1] ))/g
This commit is contained in:
2020-12-28 02:58:46 +01:00
parent 4a0b9e5cf1
commit a440e8b61e
3 changed files with 10 additions and 10 deletions

View File

@@ -48,9 +48,9 @@ conf() {
local CONF_EDITOR
if [[ -n "$EDITOR" ]]; then
CONF_EDITOR="$EDITOR"
elif command -v vim &>/dev/null; then
elif (( $+commands[vim] )); then
CONF_EDITOR=vim
elif command -v nano &>/dev/null; then
elif (( $+commands[nano] )); then
CONF_EDITOR=nano
else
CONF_EDITOR=cat

View File

@@ -1 +1 @@
! command -v direnv &>/dev/null || eval "$(direnv hook zsh)"
! (( $+commands[direnv] )) || eval "$(direnv hook zsh)"