Skip to content

Instantly share code, notes, and snippets.

@vepetkov
Created July 14, 2023 09:14
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 vepetkov/2332bf0228a1863a9c322cf3a9d9e1e5 to your computer and use it in GitHub Desktop.
Save vepetkov/2332bf0228a1863a9c322cf3a9d9e1e5 to your computer and use it in GitHub Desktop.
Load .venv automatically using DirEnv
# Store in ~/.config/direnv/direnvrc to run for all folders automatically
# check if VENV is loaded
if [[ -z "${VIRTUAL_ENV_PROMPT}" ]] ; then
if [ ! -d ".venv" ] ; then
echo "Installing virtualenv for $(python -V)"
python -m venv .venv
fi
echo "Activating $(python -V) virtualenv from .venv"
source .venv/bin/activate
fi
echo "Virtualenv has been activated for $(python -V)"
echo "$(which python)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment