Skip to content

Commit

Permalink
feat(configs): add updated python venv source function
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHepworth committed Jan 7, 2025
1 parent 7cd5cb8 commit 0e8690c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shell-configs/shell/functions/functions_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sact() {
if [ -n "$1" ]; then
venvs_to_try=("$1")
else
venvs_to_try=("venv" ".venv")
fi

for venv in "${venvs_to_try[@]}"; do
if [ -d "$venv" ]; then
echo "Activating '$venv'..."
source "$venv/bin/activate"
return 0
fi
done

echo "Error: No virtual environment found ('$(IFS=', '; echo "${venvs_to_try[*]}")')."
return 1
}

0 comments on commit 0e8690c

Please sign in to comment.