From 833e6f5958b9851d2dbcf8ae706474af4079a25e Mon Sep 17 00:00:00 2001 From: Jyrki Pulliainen Date: Wed, 7 Jan 2015 18:15:00 +0100 Subject: [PATCH] virtualenvwrapper: Deactivate only if in virtualenv If user manually deactivates the virtualenv when using this mode, zsh will produce following error: deactivate:12: command not found: virtualenv_deactivate To avoid this, check that the VIRTUAL_ENV flag is set before trying to automatically deactivate the virtual environment. Fixes #2185 --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 52e02d3e0..217ab0722 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -38,7 +38,7 @@ if (( $+commands[$virtualenvwrapper] )); then source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" fi fi - elif [ $CD_VIRTUAL_ENV ]; then + 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