mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
Change order of automatic virtualenv activation/deactivation (#6687)
When navigating from a virtualenv project directory, first deactivate the virtualenv. Then, check to see if destination directory is also a virtualenv project directory. If it is activate that virtualenv. See #5817.
This commit is contained in:
parent
3d6be08e71
commit
1a0500b00d
1 changed files with 6 additions and 4 deletions
|
@ -77,6 +77,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
||||||
else
|
else
|
||||||
ENV_NAME=""
|
ENV_NAME=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then
|
||||||
|
# We've just left the repo, deactivate the environment
|
||||||
|
# Note: this only happens if the virtualenv was activated automatically
|
||||||
|
deactivate && unset CD_VIRTUAL_ENV
|
||||||
|
fi
|
||||||
if [[ "$ENV_NAME" != "" ]]; then
|
if [[ "$ENV_NAME" != "" ]]; then
|
||||||
# Activate the environment only if it is not already active
|
# Activate the environment only if it is not already active
|
||||||
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
||||||
|
@ -86,10 +92,6 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
||||||
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
|
|
||||||
# We've just left the repo, deactivate the environment
|
|
||||||
# Note: this only happens if the virtualenv was activated automatically
|
|
||||||
deactivate && unset CD_VIRTUAL_ENV
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue