Skip to content

Instantly share code, notes, and snippets.

@tcrowe
Created June 2, 2019 16:19
Show Gist options
  • Save tcrowe/e16b15acdee83c0b39698bb0a06f2b48 to your computer and use it in GitHub Desktop.
Save tcrowe/e16b15acdee83c0b39698bb0a06f2b48 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