This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto-activate .venv when entering a directory (search up to 2 parents) | |
function auto_venv() { | |
local dir=$PWD venv_path= venv_dir= current_venv= | |
for i in {0..2}; do | |
if [[ -f "$dir/.venv/bin/activate" ]]; then | |
venv_path="$dir/.venv/bin/activate" | |
break | |
fi | |
dir="$(dirname "$dir")" | |
done |