From 17d22e7a13e972b37dee15fb62706d94842100cd Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sat, 5 Dec 2015 01:35:59 +0000 Subject: [PATCH] Add `PYENV_VIRTUAL_ENV` to check if the virtualenv has been activated via pyenv-virtualenv or not (#128) --- bin/pyenv-sh-activate | 26 +++++++++++++++++--------- bin/pyenv-sh-deactivate | 10 ++++++++-- test/activate.bats | 11 +++++++++++ test/conda-activate.bats | 6 ++++++ test/conda-deactivate.bats | 7 +++++++ test/deactivate.bats | 23 +++++++++++++++++++++++ 6 files changed, 72 insertions(+), 11 deletions(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 6966776..2d0ea5b 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -73,14 +73,16 @@ fi venv="${versions}" -# exit as success if some virtualenv outside from pyenv is already activated -if [ -n "${VIRTUAL_ENV}" ] && [[ "${VIRTUAL_ENV}" != "${PYENV_ROOT}/versions/"* ]]; then - if [ -z "${FORCE}" ]; then - if [ -z "${QUIET}" ]; then - echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2 +if [ -n "${VIRTUAL_ENV}" ]; then + # exit as success if some virtualenv is already activated outside from pyenv-virtualenv + if [ -z "${PYENV_VIRTUAL_ENV}" ]; then + if [ -z "${FORCE}" ]; then + if [ -z "${QUIET}" ]; then + echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2 + fi + echo "true" + exit 0 fi - echo "true" - exit 0 fi fi @@ -163,10 +165,16 @@ fi # virtualenv/pyvenv case "${shell}" in fish ) - echo "setenv VIRTUAL_ENV \"${prefix}\";" + cat <