# This file must be used with "source bin/activate" *from bash* # you cannot run it directly forget_cached_commands () { # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then hash -r fi } deactivate () { if [ -n "$_OLD_SANDBOX_GEM_HOME" ] ; then GEM_HOME="$_OLD_SANDBOX_GEM_HOME" export GEM_HOME else unset GEM_HOME fi if [ -n "$_OLD_SANDBOX_GEM_PATH" ] ; then GEM_PATH="$_OLD_SANDBOX_GEM_PATH" export GEM_PATH else unset GEM_PATH fi if [ -n "$_OLD_SANDBOX_PATH" ] ; then PATH="$_OLD_SANDBOX_PATH" export PATH fi if [ -n "$_OLD_SANDBOX_HOME" ] ; then HOME="$_OLD_SANDBOX_HOME" export HOME fi if [ -n "$_OLD_SANDBOX_PS1" ] ; then PS1="$_OLD_SANDBOX_PS1" export PS1 fi unset _OLD_SANDBOX_PATH unset _OLD_SANDBOX_HOME unset _OLD_SANDBOX_GEM_HOME unset _OLD_SANDBOX_GEM_PATH unset _OLD_SANDBOX_PS1 unset SANDBOX_ENV forget_cached_commands if [ ! "$1" = "nondestructive" ] ; then # Self destruct! unset deactivate unset forget_cached_commands fi } activate () { # unset irrelavent variables deactivate nondestructive # preserve current variables _OLD_SANDBOX_GEM_HOME="$GEM_HOME" _OLD_SANDBOX_GEM_PATH="$GEM_PATH" _OLD_SANDBOX_PATH="$PATH" _OLD_SANDBOX_HOME="$HOME" _OLD_SANDBOX_PS1="$PS1" # set the sandbox-aware states SANDBOX_ENV="<%= target %>" PATH="$SANDBOX_ENV/bin:$PATH" HOME="$SANDBOX_ENV" GEM_HOME="$SANDBOX_ENV/rubygems" GEM_PATH="$GEM_HOME" if [ "`basename \"$SANDBOX_ENV\"`" = "__" ] ; then # special case for Aspen magic directories # see http://www.zetadev.com/software/aspen/ PS1="[ruby-virtualenv:`basename \`dirname \"$SANDBOX_ENV\"\``] $PS1" else PS1="(ruby-virtualenv:`basename \"$SANDBOX_ENV\"`) $PS1" fi export SANDBOX_ENV PATH HOME GEM_HOME GEM_PATH PS1 forget_cached_commands unset activate } activate # Thanks to the virtualenv developers (http://pypi.python.org/pypi/virtualenv)