Skip to content

Instantly share code, notes, and snippets.

@faulkner
Created July 2, 2012 01:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faulkner/3030490 to your computer and use it in GitHub Desktop.
Save faulkner/3030490 to your computer and use it in GitHub Desktop.
A few bash functions for autoenv
# 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