Use in Virtualenvwrapper plugin

This commit is contained in:
Capi Etheriel 2013-04-27 01:03:52 -03:00
commit bce83c941e

View file

@ -7,10 +7,10 @@ if [[ -f "$wrapsource" ]]; then
# Automatically activate Git projects' virtual environments based on the # Automatically activate Git projects' virtual environments based on the
# directory name of the project. Virtual environment name can be overridden # directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it # by placing a .venv file in the project root with a virtualenv name in it
function workon_cwd { function _workon_cwd {
# Check that this is a Git repo # Check that this is a Git repo
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` PROJECT_ROOT=`git_get_root`
if (( $? == 0 )); then if [[ -n "$PROJECT_ROOT" ]]; then
# Check for virtualenv name override # Check for virtualenv name override
ENV_NAME=`basename "$PROJECT_ROOT"` ENV_NAME=`basename "$PROJECT_ROOT"`
if [[ -f "$PROJECT_ROOT/.venv" ]]; then if [[ -f "$PROJECT_ROOT/.venv" ]]; then
@ -28,11 +28,12 @@ if [[ -f "$wrapsource" ]]; then
deactivate && unset CD_VIRTUAL_ENV deactivate && unset CD_VIRTUAL_ENV
fi fi
unset PROJECT_ROOT unset PROJECT_ROOT
unset ENV_NAME
} }
# New cd function that does the virtualenv magic # New cd function that does the virtualenv magic
function cd { function cd {
builtin cd "$@" && workon_cwd builtin cd "$@" && _workon_cwd
} }
fi fi
else else