Skip to content

Instantly share code, notes, and snippets.

@shaybix
Forked from tcrowe/binary-command-exists.zsh
Created February 24, 2024 07:16
Show Gist options
  • Save shaybix/be0b38cbacb4d50b8411276c9dcfd920 to your computer and use it in GitHub Desktop.
Save shaybix/be0b38cbacb4d50b8411276c9dcfd920 to your computer and use it in GitHub Desktop.
Bash or ZSH: Check if a binary or command exists
# which goes into dev null
# $? is the magic that tells us if it worked 0 = exists
if [[ `which nvm &>/dev/null && $?` != 0 ]]; then
source ~/.nvm/nvm.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment