Created
May 16, 2016 09:35
-
-
Save hugopeixoto/29425b755355c283c0a0a81aaa614e6b to your computer and use it in GitHub Desktop.
activate for python and npm
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
activate() { | |
py=".env/bin/activate" | |
[ -f "$py" ] && . "$py" | |
js="node_modules" | |
if [ -d "$js" ]; then | |
export _PREV_PATH_WITHOUT_NPM="$PATH" | |
export _PREV_PS1_WITHOUT_NPM="$PS1" | |
export PATH="$(npm bin):$PATH" | |
export PS1="(npm:$(basename "$PWD"))$PS1" | |
deactivate() { | |
echo "deactivating" | |
export PATH="$_PREV_PATH_WITHOUT_NPM" | |
export PS1="$PS1" | |
unset -f deactivate | |
} | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment