Skip to content

Instantly share code, notes, and snippets.

@dansalias
Created December 9, 2019 19:14
Show Gist options
  • Save dansalias/befe9f1e6bbcb17bc2a37bd517f8fc03 to your computer and use it in GitHub Desktop.
Save dansalias/befe9f1e6bbcb17bc2a37bd517f8fc03 to your computer and use it in GitHub Desktop.
Switch node versions without nvm
# node-switch alias
alias ns=$HOME/scripts/node-switch.sh
# switch node version based on .nvmrc
default_node_version=12.13.1
chpwd() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
ns switch "$(< .nvmrc)"
elif [[ $(node --version) != v$default_node_version ]]; then
ns switch $default_node_version
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment