mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
better impl
This commit is contained in:
parent
1965d1b3fc
commit
9d99b97a7d
1 changed files with 13 additions and 14 deletions
|
|
@ -87,21 +87,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
|
||||||
function auto_vrun() {
|
function auto_vrun() {
|
||||||
local dirname="$PWD"
|
# deactivate if we're on a different dir than VIRTUAL_ENV states
|
||||||
|
# we don't deactivate subdirectories!
|
||||||
|
if (( $+functions[deactivate] )) && [[ $PWD != ${VIRTUAL_ENV:h}* ]]; then
|
||||||
|
deactivate > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
while
|
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
|
||||||
for activator in "${dirname}/${PYTHON_VENV_NAME}"*/bin/activate(N); do
|
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do
|
||||||
if [[ -f "${activator}" ]]; then
|
# make sure we're not in a venv already
|
||||||
source "${activator}" > /dev/null 2>&1
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||||
return
|
source $_file > /dev/null 2>&1
|
||||||
fi
|
break
|
||||||
done
|
done
|
||||||
[[ -n "$dirname" ]]
|
fi
|
||||||
do
|
|
||||||
dirname=${dirname%/*}
|
|
||||||
done
|
|
||||||
|
|
||||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
|
||||||
}
|
}
|
||||||
add-zsh-hook chpwd auto_vrun
|
add-zsh-hook chpwd auto_vrun
|
||||||
auto_vrun
|
auto_vrun
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue