Last active
June 5, 2018 09:00
-
-
Save rthill/6a663577f7fb17e747699dec668d25bc to your computer and use it in GitHub Desktop.
Python virtualenv wrapper script
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
Add into your .bashrc on macOS the following alias: | |
alias workon='source ~/bin/workon.sh' | |
I believe on Linux the alias should look like: | |
alias workon='~/bin/workon.sh' |
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
#!/bin/sh | |
# | |
# Workon virtualenv wrapper | |
# | |
VENVDIR=~/Pyenv | |
ENV=$1 | |
DIR=`find $VENVDIR -maxdepth 1 -type d -iname $ENV -print -quit` | |
if [[ ! -z "${DIR}" ]]; then | |
echo "Activating virtualenv $ENV" | |
if [[ ! -z "$VIRTUAL_ENV" ]]; then | |
echo "Deactivating old virtualenv" | |
deactivate | |
fi | |
source $DIR/bin/activate | |
else | |
echo "Cannot find virtualenv!" | |
echo "Valid virtualenvs:" | |
find $VENVDIR -maxdepth 1 -type d -execdir echo " {}" \; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment