Something went wrong. Try again.
Small utility to activate python venvs without hassle
Something went wrong. Try again.
123456789101112131415161718192021222324# Utility command to activate local Python venv# located at the same folder of the code project
function activate() { local current_folder=$(basename "$PWD") local venv_candidates=(".venv" "venv" ".env" ".hatch/${current_folder}") local venv local candidate
for candidate in $venv_candidates; do if [[ -d "$candidate" ]]; then venv=$candidate fi done
venv="${venv}/bin/activate"
if [[ -f "$venv" ]]; then source "$venv" else echo "venv not found" fi}