mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-26 18:33:03 +01:00
feat(python): add recursive parent directory search for auto_vrun (#13523)
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -113,8 +113,23 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||
# make sure we're not in a venv already
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
source $file > /dev/null 2>&1
|
||||
break
|
||||
return
|
||||
done
|
||||
|
||||
# Search parent directories if recursive mode is enabled, stopping before $HOME
|
||||
if [[ "$PYTHON_AUTO_VRUN_RECURSIVE" == "true" ]]; then
|
||||
local search_dir="$PWD:h"
|
||||
while [[ "$search_dir" != "/" && "$search_dir" != "." && "$search_dir" != "$HOME" ]]; do
|
||||
for file in "${search_dir}/"${^PYTHON_VENV_NAMES[@]}"/bin/activate"(N.); do
|
||||
# the venv found is already active
|
||||
[[ "${file:h:h:A}" == "${VIRTUAL_ENV:A}" ]] && return
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
source $file > /dev/null 2>&1
|
||||
return
|
||||
done
|
||||
search_dir="${search_dir:h}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
add-zsh-hook chpwd auto_vrun
|
||||
|
||||
Reference in new issue
Block a user