Created
August 2, 2016 18:27
-
-
Save bmuller/eb79ba3e5cda2c0d03ad488125075790 to your computer and use it in GitHub Desktop.
venv function for dealing with virtualenv
This file contains hidden or 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
function venv { | |
if [ "$1" == "" ]; then | |
echo "Currently using python in: " | |
dirname $(dirname $(which python)) | |
echo | |
echo "Use: 'venv <name> [version]' to change. Version is 2.7 by default" | |
else | |
mkdir -p $HOME/.virtualenvs | |
if [ ! -d "$HOME/.virtualenvs/$1" ]; then | |
if [ "$2" == "" ]; then | |
/usr/local/bin/virtualenv $HOME/.virtualenvs/$1 | |
else | |
/usr/local/bin/virtualenv $HOME/.virtualenvs/$1 -p python$2 | |
fi | |
. $HOME/.virtualenvs/$1/bin/activate | |
pip install --upgrade pip | |
else | |
. $HOME/.virtualenvs/$1/bin/activate | |
fi | |
echo "Using virtual env in $HOME/.virtualenvs/$1; use 'deactivate' to disable." | |
export PS1="\u@\h \w$ " | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment