Skip to content

Instantly share code, notes, and snippets.

@tcgarvin
Last active March 24, 2020 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcgarvin/5ace90ca0fe81ffddb2e4657c341fece to your computer and use it in GitHub Desktop.
Save tcgarvin/5ace90ca0fe81ffddb2e4657c341fece to your computer and use it in GitHub Desktop.
Bash function to deactivate the current virtual environment and activate the one in the present directory
#!/bin/bash
# Bash function to deactivate the current virtual environment and activate the one in the present directory
venv () {
if [ -f "venv/bin/activate" ]; then
if [ "`type -t deactivate`" = "function" ]; then
echo "Deactivating venv in anticipation of a new one"
deactivate
fi
echo "Activating venv at `pwd`"
source venv/bin/activate
else
echo "No venv found at `pwd`"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment