Created
April 11, 2019 02:03
-
-
Save aultl/3ab08c567ff9af1356a2f900e6900dbd to your computer and use it in GitHub Desktop.
python virtualenv wrapper
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
function mkvenv () | |
{ | |
VIRTUAL_ENV_HOME=~/.virtualenvs; | |
case ${1} in | |
add) | |
if [[ -d $VIRTUAL_ENV_HOME/$2 ]]; then | |
echo "Virtual Env Directory exists!"; | |
exit 1; | |
else | |
python3 -m venv $VIRTUAL_ENV_HOME/$2; | |
fi | |
;; | |
list) | |
ls -l ${VIRTUAL_ENV_HOME}/ | |
;; | |
del) | |
if [[ -d $VIRTUAL_ENV_HOME/$2 ]]; then | |
rm -rf $VIRTUAL_ENV_HOME/${2}; | |
else | |
echo "Virtual Env Directory does not exists!"; | |
exit 1; | |
fi | |
;; | |
init) | |
if [[ -d $VIRTUAL_ENV_HOME/$2 ]]; then | |
source $VIRTUAL_ENV_HOME/$2/bin/activate; | |
else | |
echo "Virtual Env Directory does not exist!"; | |
exit 1; | |
fi | |
;; | |
*) | |
echo "Usage: mkvenv {add|list|del|init} env" | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment