Skip to content

Instantly share code, notes, and snippets.

@hugopeixoto
Created May 16, 2016 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugopeixoto/29425b755355c283c0a0a81aaa614e6b to your computer and use it in GitHub Desktop.
Save hugopeixoto/29425b755355c283c0a0a81aaa614e6b to your computer and use it in GitHub Desktop.
activate for python and npm
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