Skip to content

Instantly share code, notes, and snippets.

@hodgestar
Created March 3, 2017 12:42
Show Gist options
  • Save hodgestar/83ced1bb24a32e3ec946da8309867fd8 to your computer and use it in GitHub Desktop.
Save hodgestar/83ced1bb24a32e3ec946da8309867fd8 to your computer and use it in GitHub Desktop.
Script for creating virtualenvs.
#!/bin/bash -e
#
# In .bashrc or similar do:
#
# $ source /path/to/lve
#
# Then later in a repository folder just:
#
# $ lve
#
# to create or activate a virtualenv, or
#
# $ lve3
#
# for Python 3.
function lve () {
if [ -n "$1" ]
then
VENV="$1"
else
VENV=`basename "$PWD"`
fi
VENV_PATH="/home/$USER/venvs/$VENV"
if [ ! -e "$VENV_PATH" ]
then
virtualenv "$VENV_PATH"
fi
unset VENV
source "$VENV_PATH/bin/activate"
}
function lve3 () {
if [ -n "$1" ]
then
VENV="$1"
else
VENV=`basename "$PWD"`
fi
VENV_PATH="/home/$USER/venvs/$VENV"
if [ ! -e "$VENV_PATH" ]
then
virtualenv -p python3 "$VENV_PATH"
fi
unset VENV
source "$VENV_PATH/bin/activate"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment