Files
pyenv-virtualenv/bin/pyenv-sh-deactivate
2014-07-04 22:10:35 +09:00

66 lines
1007 B
Bash
Executable File

#!/usr/bin/env bash
#
# Summary: Deactivate virtual environment
#
# Usage: pyenv deactivate
#
# Deactivate a Python virtual environment.
set -e
[ -n "$PYENV_DEBUG" ] && set -x
unset NOERROR
if [ "$1" = "--no-error" ]; then
NOERROR=1
shift 1
fi
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
case "$shell" in
fish )
echo "if functions -q deactivate"
;;
* )
echo "if declare -f deactivate 1>/dev/null 2>&1; then"
;;
esac
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
# Backward compatibility issue
# https://github.com/yyuu/pyenv-virtualenv/issues/26
echo " pyenv shell --unset;"
fi
case "$shell" in
fish )
cat <<EOS
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
deactivate;
else;
EOS
;;
* )
cat <<EOS
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
deactivate;
else
EOS
;;
esac
if [ -z "$NOERROR" ]; then
echo " echo \"pyenv-virtualenv: no virtualenv has been activated.\" 1>&2;"
fi
echo " false;"
case "$shell" in
fish )
echo "end;"
;;
* )
echo "fi;"
;;
esac