Created
October 1, 2012 02:52
-
-
Save leeadkins/3809218 to your computer and use it in GitHub Desktop.
Super simple hack to automatically switch to a specific Node version on CD (using NVM and ZSH)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detects if a .nvmrc file exists, and switches | |
# to the specified version if it does. | |
# The contents of the .nvmrc file should simply be the node | |
# version to use, like "v0.8.11" | |
# Put this in your .zshrc file or somewhere else that is loaded automatically | |
function chpwd() { | |
emulate -L zsh | |
if [[ -f .nvmrc ]] then | |
nvm use `cat .nvmrc` | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need to cat the contents of the nvmrc file into
nvm use
, the default behavior ofnvm use
is to look for a nvmrc file and use that, so you could just do: