mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-25 00:10:59 +02:00
README: improve recipe for virtualenv auto-activation
- check that VIRTUAL_ENV is non-empty, which might happen when `deactivate` was called already. - perform directory name abbreviation on the virtualenv path.
This commit is contained in:
parent
4aeb48a02e
commit
9ecb91480d
@ -161,17 +161,17 @@ if [[ $autoenv_event == 'enter' ]]; then
|
|||||||
local -a venv
|
local -a venv
|
||||||
venv=(./(../)#.venv(NY1:A))
|
venv=(./(../)#.venv(NY1:A))
|
||||||
|
|
||||||
if [[ -n "$_ZSH_ACTIVATED_VIRTUALENV" ]]; then
|
if [[ -n "$_ZSH_ACTIVATED_VIRTUALENV" && -n "$VIRTUAL_ENV" ]]; then
|
||||||
if ! (( $#venv )) || [[ "$_ZSH_ACTIVATED_VIRTUALENV" != "$venv[1]" ]]; then
|
if ! (( $#venv )) || [[ "$_ZSH_ACTIVATED_VIRTUALENV" != "$venv[1]" ]]; then
|
||||||
echo "De-activating virtualenv: $VIRTUAL_ENV" >&2
|
|
||||||
deactivate
|
|
||||||
unset _ZSH_ACTIVATED_VIRTUALENV
|
unset _ZSH_ACTIVATED_VIRTUALENV
|
||||||
|
echo "De-activating virtualenv: ${(D)VIRTUAL_ENV}" >&2
|
||||||
|
deactivate
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$VIRTUAL_ENV" ]]; then
|
if [[ -z "$VIRTUAL_ENV" ]]; then
|
||||||
if (( $#venv )); then
|
if (( $#venv )); then
|
||||||
echo "Activating virtualenv: $venv" >&2
|
echo "Activating virtualenv: ${(D)venv}" >&2
|
||||||
source $venv[1]/bin/activate
|
source $venv[1]/bin/activate
|
||||||
_ZSH_ACTIVATED_VIRTUALENV="$venv[1]"
|
_ZSH_ACTIVATED_VIRTUALENV="$venv[1]"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user