Skip to content

Instantly share code, notes, and snippets.

@turtlebender
Created November 20, 2012 22:06
Show Gist options
  • Save turtlebender/4121572 to your computer and use it in GitHub Desktop.
Save turtlebender/4121572 to your computer and use it in GitHub Desktop.
Add to your ~/.profile to easily activate the snake virtualenv

One thing people always want is the ability to easily use the virtualenv created by snakegit. Here is an easy way to accomplish that. If you add these functions to either your ~/.bash_profile or your ~/.profile file, then you will have 2 new commands you can run. N.B. you can call the functions whatever you want, but snakeskin and shed are kinda cute and came from Walt

# in your project directory call snakeskin to activate
function snakeskin()
{
  export OLDPATH=$PATH
  test -f snake.cfg || (echo "Not a snake project" ; return 0)
  test -f vendor/python/bin/activate || git snake build
  source vendor/python/bin/activate
  export PATH=$PATH:~/.snakegit/bin
}

# when you are done call shed to deactivate the virtualenv
# to return your previous environment
function shed()
{
  deactivate > /dev/null 2>&1 ; true
  export PATH=$OLDPATH
}

Right after you add these, you'll need to source the file you edited to get these functions in your environment.

source ~/.bash_profile

or

source ~/.profile

Now, if you are in the project directory and you call snakeskin you will have the virtualenv activated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment