Small utility to activate python venvs without hassle
0

Configure Feed

Select the types of activity you want to include in your feed.

activate / activate.plugin.zsh
500 B 23 lines
1# Utility command to activate local Python venv 2# located at the same folder of the code project 3 4function activate() { 5 local current_folder=$(basename "$PWD") 6 local venv_candidates=(".venv" "venv" ".env" ".hatch/${current_folder}") 7 local venv 8 local candidate 9 10 for candidate in $venv_candidates; do 11 if [[ -d "$candidate" ]]; then 12 venv=$candidate 13 fi 14 done 15 16 venv="${venv}/bin/activate" 17 18 if [[ -f "$venv" ]]; then 19 source "$venv" 20 else 21 echo "venv not found" 22 fi 23}