feat(python): don't auto-deactivate in a subdir

This commit is contained in:
Feasuro 2024-05-04 15:56:02 +02:00
commit 1965d1b3fc
No known key found for this signature in database
GPG key ID: 4EB3F9F0ED4AD469
2 changed files with 15 additions and 8 deletions

View file

@ -86,12 +86,19 @@ function mkv() {
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
# Automatically activate venv when changing dir
auto_vrun() {
for activator in "${PYTHON_VENV_NAME}"*/bin/activate(N); do
if [[ -f "${activator}" ]]; then
source "${activator}" > /dev/null 2>&1
return
fi
function auto_vrun() {
local dirname="$PWD"
while
for activator in "${dirname}/${PYTHON_VENV_NAME}"*/bin/activate(N); do
if [[ -f "${activator}" ]]; then
source "${activator}" > /dev/null 2>&1
return
fi
done
[[ -n "$dirname" ]]
do
dirname=${dirname%/*}
done
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1