Created
July 2, 2012 01:59
-
-
Save faulkner/3030490 to your computer and use it in GitHub Desktop.
A few bash functions for autoenv
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
# based on https://github.com/kennethreitz/autoenv/wiki/Cookbook | |
# using virtualenvwrapper? | |
use_env() { | |
if [ -n "$1" ]; then | |
venv="$1" | |
else | |
venv=$(basename `pwd`) | |
fi | |
if [[ `basename "${VIRTUAL_ENV:t}"` != "$venv" ]]; then | |
if workon | grep $venv > /dev/null; then | |
workon "$venv" | |
else | |
mkvirtualenv "$venv" | |
fi | |
fi | |
} | |
# kickin it old school? | |
local_env() { | |
if [ -n "$1" ]; then | |
venv="$1" | |
else | |
venv="env" # or .venv, whatever | |
fi | |
if [ -d $venv ]; then | |
source $venv/bin/activate | |
else | |
virtualenv --no-site-packages $venv | |
source $venv/bin/activate | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment