Skip to content

Instantly share code, notes, and snippets.

@yareally
Created September 23, 2013 08:59
Show Gist options
  • Save yareally/6668118 to your computer and use it in GitHub Desktop.
Save yareally/6668118 to your computer and use it in GitHub Desktop.
#!/bin/sh
# venv_switch.sh
# switch between different virtual environments
# verify a virtualenv is passed in
if [ $# -ne 1 ]
then
echo 'Usage: venv_switch venv-label'
exit -1
fi
# verify the virtualenv exists
VENV_PATH=~/python-projects/virtualenv/$1
# activate env script
ACTIVATE_ENV=~/python-projects/virtualenv/activate
echo $VENV_PATH
if [ -e $VENV_PATH ]
then
echo 'Switching to virtualenv' $VENV_PATH
echo "Starting new bash shell. Simply 'exit' to return to previous shell"
else
echo 'Error: virtualenv' $VENV_PATH 'does not exist!'
exit -1
fi
rm $ACTIVATE_ENV
ln -s ~/python-projects/virtualenv/$1/bin/activate $ACTIVATE_ENV
# Launch new terminal
bash --rcfile ~/.virtualenvrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment