mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-12-21 10:20:15 +02:00
README: improve .venv example
This commit is contained in:
parent
c60241f9d9
commit
e9809c1bd2
17
README.md
17
README.md
@ -191,20 +191,31 @@ if [[ $autoenv_event == 'enter' ]]; then
|
||||
|
||||
setopt localoptions extendedglob
|
||||
local -a venv
|
||||
venv=(./(../)#.venv(NY1:a))
|
||||
venv=(./(../)#.venv(NY1:A))
|
||||
|
||||
if [[ -n "$_ZSH_ACTIVATED_VIRTUALENV" && -n "$VIRTUAL_ENV" ]]; then
|
||||
if ! (( $#venv )) || [[ "$_ZSH_ACTIVATED_VIRTUALENV" != "$venv[1]" ]]; then
|
||||
unset _ZSH_ACTIVATED_VIRTUALENV
|
||||
echo "De-activating virtualenv: ${(D)VIRTUAL_ENV}" >&2
|
||||
deactivate
|
||||
|
||||
# Simulate "deactivate", but handle $PATH better (remove VIRTUAL_ENV).
|
||||
if ! autoenv_remove_path $VIRTUAL_ENV/bin; then
|
||||
echo "warning: ${VIRTUAL_ENV}/bin not found in \$PATH" >&2
|
||||
fi
|
||||
|
||||
# NOTE: does not handle PYTHONHOME/_OLD_VIRTUAL_PYTHONHOME
|
||||
unset _OLD_VIRTUAL_PYTHONHOME
|
||||
# NOTE: does not handle PS1/_OLD_VIRTUAL_PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
unset VIRTUAL_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$VIRTUAL_ENV" ]]; then
|
||||
if (( $#venv )); then
|
||||
echo "Activating virtualenv: ${(D)venv}" >&2
|
||||
source $venv[1]/bin/activate
|
||||
export VIRTUAL_ENV=$venv[1]
|
||||
autoenv_prepend_path $VIRTUAL_ENV/bin
|
||||
_ZSH_ACTIVATED_VIRTUALENV="$venv[1]"
|
||||
fi
|
||||
fi
|
||||
|
@ -476,6 +476,7 @@ _autoenv_chpwd_handler() {
|
||||
fi
|
||||
|
||||
if ! _autoenv_check_authorized_env_file $env_file; then
|
||||
_autoenv_debug "Not authorized: $env_file"
|
||||
return
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user