Bash: venv sourcing function
This commit is contained in:
parent
b09b3531d3
commit
02a8705c0a
1 changed files with 19 additions and 0 deletions
|
@ -428,4 +428,23 @@ if [[ "$EUID" -eq 0 ]]; then
|
|||
complete -F _restic_env restic_env
|
||||
fi
|
||||
|
||||
# Python virtual environments =======================================
|
||||
loadvenv() {
|
||||
local init_dir="$PWD"
|
||||
|
||||
while [[ "$PWD" != "/" ]]; do
|
||||
for x in $(fd -HI -td --maxdepth=1); do
|
||||
if [[ "$x" == '.venv/' || "$x" == 'venv/' ]]; then
|
||||
source "${x}/bin/activate"
|
||||
cd "$init_dir"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
||||
done
|
||||
|
||||
cd "$init_dir"
|
||||
}
|
||||
|
||||
# vim: set ft=bash ff=unix:
|
||||
|
|
Loading…
Reference in a new issue