Skip to content

Instantly share code, notes, and snippets.

@dsaad68
Created February 12, 2025 11:52
Show Gist options
  • Save dsaad68/41edce587e7ee72f4b6376aaee921c26 to your computer and use it in GitHub Desktop.
Save dsaad68/41edce587e7ee72f4b6376aaee921c26 to your computer and use it in GitHub Desktop.
Python Env Auto Activator
## 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