-
-
Save hodgestar/83ced1bb24a32e3ec946da8309867fd8 to your computer and use it in GitHub Desktop.
Script for creating virtualenvs.
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
#!/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