Skip to content

Instantly share code, notes, and snippets.

@spudfkc
Created February 13, 2014 02:22
Show Gist options
  • Save spudfkc/8968611 to your computer and use it in GitHub Desktop.
Save spudfkc/8968611 to your computer and use it in GitHub Desktop.
makes a python virtualenv from the name of the current directory. stores all virtualenvs in a common location
#!/bin/bash
#
# usage: mkvirtualenv [any virtualenv params]
#
# Creates a virtualenv in the directory defined by STORE using the current
# directory's name as the virtualenv name.
#
STORE="/home/$USER/.virtualenv/env"
if [ ! -d $STORE ]
then
echo "Virtualenv storage does not exist!"
echo "Creating storage: $STORE"
mkdir -p $STORE
fi
VIRTUAL_ENV=$(which virtualenv)
ENV_NAME=$(basename $(pwd))
if [[ "$ENV_NAME" == "." ]]
then
echo "is ."
fi
echo "Making virtualenv: $ENV_NAME"
PARAMS="$@ $STORE/$ENV_NAME"
exec $VIRTUAL_ENV $PARAMS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment