Created
January 23, 2020 11:16
-
-
Save pinealan/d26f01bc187e6ef621be0d22576bf655 to your computer and use it in GitHub Desktop.
Bash snippet for easy access to venv
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
venv() { | |
# use global venvs from $HOME if arg is provided | |
if [[ -n $1 ]]; then | |
. ~/venv/$1/bin/activate | |
return | |
fi | |
# look for a venv in current directory | |
for dir in "venv" ".venv" "env" ".env"; do | |
if [[ -d $dir ]]; then | |
. $dir/bin/activate | |
return | |
fi | |
done | |
# exit with error | |
echo ERROR: Unable to find local environment >&2 | |
return 127 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Project specific virtual environments
System wide virtual environments