Created
February 12, 2025 11:52
-
-
Save dsaad68/41edce587e7ee72f4b6376aaee921c26 to your computer and use it in GitHub Desktop.
Python Env Auto Activator
This file contains 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
## Python Enviornment Activation | |
alias activate-venv='source .venv/bin/activate' | |
# Function to source .venv if it exists | |
auto_source_env() { | |
if [[ -d ".venv" && -f ".venv/bin/activate" ]]; then | |
echo "Activating virtual environment in .venv..." | |
activate-venv | |
fi | |
} | |
# Hook to run the function on directory change | |
chpwd() { | |
auto_source_env | |
} | |
# Run on shell start for the current directory | |
auto_source_env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment