|
|
|
@ -86,11 +86,20 @@ function mkv() { |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then |
|
|
|
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then |
|
|
|
# Automatically activate venv when changing dir |
|
|
|
# Automatically activate venv when changing dir |
|
|
|
auto_vrun() { |
|
|
|
function auto_vrun() { |
|
|
|
if [[ -f "${PYTHON_VENV_NAME}/bin/activate" ]]; then |
|
|
|
# deactivate if we're on a different dir than VIRTUAL_ENV states |
|
|
|
source "${PYTHON_VENV_NAME}/bin/activate" > /dev/null 2>&1 |
|
|
|
# we don't deactivate subdirectories! |
|
|
|
else |
|
|
|
if (( $+functions[deactivate] )) && [[ $PWD != ${VIRTUAL_ENV:h}* ]]; then |
|
|
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 |
|
|
|
deactivate > /dev/null 2>&1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then |
|
|
|
|
|
|
|
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do |
|
|
|
|
|
|
|
# make sure we're not in a venv already |
|
|
|
|
|
|
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 |
|
|
|
|
|
|
|
source $_file > /dev/null 2>&1 |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
done |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
add-zsh-hook chpwd auto_vrun |
|
|
|
add-zsh-hook chpwd auto_vrun |
|
|
|
|