Created
January 3, 2026 11:33
-
-
Save GeroZayas/508c7f980191e19d9e4b24fd5f312ec7 to your computer and use it in GitHub Desktop.
ACT Alias to activate virtual env easily (Python)
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
| # Activates a Python virtual environment by searching for common directory names. | |
| function act { | |
| for venv_dir in .venv venv env .env; do | |
| if [ -f "$venv_dir/bin/activate" ]; then | |
| . "$venv_dir/bin/activate" | |
| echo "Virtual environment activated: '$venv_dir'" | |
| return 0 | |
| fi | |
| done | |
| echo "Error: No virtual environment found." >&2 | |
| echo "Looked for: .venv, venv, env, .env" >&2 | |
| return 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment