Created
September 23, 2013 08:59
-
-
Save yareally/6668118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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