Created
March 16, 2015 08:45
-
-
Save awbacker/2f3eaf1f1766914dd499 to your computer and use it in GitHub Desktop.
Simple script to load a python virtual env from either ./venv/, a '.venv' file, or a global venv directory
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
venvnow () | |
{ | |
venv_default_root=~/dev/venvs; | |
cur_dir=`pwd`; | |
if [ -d venv ]; then | |
echo " - found local ./venv/, using that"; | |
source ./venv/bin/activate; | |
return 0; | |
fi; | |
if [ -f '.venv' ]; then | |
venv_name=$(<.venv); | |
echo " - using .venv file : $venv_default_root/$venv_name"; | |
source $venv_default_root/$venv_name/bin/activate; | |
return 0; | |
fi; | |
venv_name=$(basename "$cur_dir"); | |
if [ -d $venv_default_root/$venv_name ]; then | |
echo " - using current dir name: {root:$venv_default_root}/$venv_name"; | |
source $venv_default_root/$venv_name/bin/activate; | |
return 0; | |
fi; | |
echo " - unable to set venv" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment