chore: new architecture
This commit is contained in:
parent
f829660dd2
commit
09d10041d2
5 changed files with 67 additions and 30 deletions
plugins
25
plugins/python.zsh
Normal file
25
plugins/python.zsh
Normal file
|
@ -0,0 +1,25 @@
|
|||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd __python_change_venv
|
||||
|
||||
function __python_change_venv() {
|
||||
local _path=$(pwd)
|
||||
local _paths="${_path}"
|
||||
|
||||
while [[ "${_path}" != "${HOME}" ]] && [[ "${_path}" != "/" ]]; do
|
||||
_path="${_path:h}"
|
||||
_paths="${_paths} ${_path}"
|
||||
done
|
||||
|
||||
for _p in ${(z)_paths}; do
|
||||
local _venv_config=$(find "${_path}" -maxdepth 2 -mindepth 2 -name pyvenv.cfg 2>/dev/null | head -n1)
|
||||
if [[ ${_venv_config} != "" ]]; then
|
||||
local _venv_path="${_venv_config:h}"
|
||||
source "${_venv_path}/bin/activate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "${VIRTUAL_ENV}" == "" ]]; then
|
||||
source "${DEFAULT_PYTHON_VENV}/bin/activate"
|
||||
fi
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue