-
-
Save nitayneeman/0315a7022cefdea1a89e9a33c2569215 to your computer and use it in GitHub Desktop.
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
# NVM version shortcut | |
# change title name of tab in terminal | |
function title { | |
echo -ne "\033]0;"$*"\007" | |
} | |
cd() { | |
builtin cd "$@" || return | |
#echo $PREV_PWD | |
if [ "$PWD" != "$PREV_PWD" ]; then | |
PREV_PWD="$PWD"; | |
title $(echo ${PWD##*/}) $(node -v); | |
if [ -e ".nvmrc" ]; then | |
nvm use; | |
# set tab terminal name to be cwd and node version | |
title $(echo ${PWD##*/}) $(node -v); | |
else | |
nvm use default; | |
fi | |
fi | |
} | |
# Credits: | |
# Justin Noel for the gist | |
# Blake Johnston for the `.bash_profile` script | |
# More details and usage for zsh : https://medium.com/@kinduff/automatic-version-switch-for-nvm-ff9e00ae67f3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment