Skip to content

Instantly share code, notes, and snippets.

@hectorcanto
Last active August 8, 2018 11:01
Show Gist options
  • Save hectorcanto/67c754ba62f8a882898f8a004458d13e to your computer and use it in GitHub Desktop.
Save hectorcanto/67c754ba62f8a882898f8a004458d13e to your computer and use it in GitHub Desktop.
Scripts to create and activate virtualenvs according to env_$current_folder syntax
result=${PWD##*/}
folder=env_$result
path=env_$result/bin/activate
if [ ! -d "$folder" ];
then echo "Virtualenv not present in the current folder '$PWD'."
else . $path
fi
# Should be sourced(.) in ./bashrc
alias activate='. ~/.activate'
alias venv='. ~/.venv
if [ $# -eq 0 ]
then
echo "No arguments supplied. Usage venv 2.7|3.5|3.6"
exit
else
case "$1" in
2.7) echo "Python 2.7 selected.";;
3.5) echo "Python 3.5 selected.";;
3.6) echo "Python 3.6 selected.";;
*) echo "Invalid option. Usage venv 2.7|3.5|3.6"
exit;;
esac
fi
interpreter="python$1"
result=${PWD##*/}
folder=env_$result
path=env_$result/bin/activate
if [ -d "$folder" ];
then
echo "Virtualenv $folder already present."
else
virtualenv -p $interpreter $folder
fi
# Activates the
. $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment