Last active
August 8, 2018 11:01
-
-
Save hectorcanto/67c754ba62f8a882898f8a004458d13e to your computer and use it in GitHub Desktop.
Scripts to create and activate virtualenvs according to env_$current_folder syntax
This file contains 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
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 |
This file contains 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
# Should be sourced(.) in ./bashrc | |
alias activate='. ~/.activate' | |
alias venv='. ~/.venv |
This file contains 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
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