-
-
Save uglygus/7c366bfdb4dca227755510b66ab17c86 to your computer and use it in GitHub Desktop.
Python 3 venv wrapper. Manages all virtual environments under ~/.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
# venv_wrapper, manage all virtual environments under ~/.venv/ | |
# Include following in .bashrc / .bash_profile / .zshrc | |
# See https://gist.github.com/dbtek/fb2ddccb18f0cf63a654ea2cc94c8f19 | |
# Usage | |
# $ mkvenv myvirtualenv # creates venv under ~/.venv/ | |
# $ venv myvirtualenv # activates venv | |
# $ deactivate # deactivates venv | |
# $ rmvenv myvirtualenv # removes venv | |
export VENV_HOME="$HOME/.venv" | |
[[ -d $VENV_HOME ]] || mkdir $VENV_HOME | |
lsvenv() { | |
ls -1 $VENV_HOME | |
} | |
venv() { | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide venv name" | |
else | |
source "$VENV_HOME/$1/bin/activate" | |
fi | |
} | |
mkvenv() { | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide venv name" | |
else | |
echo "Creating venv under $VENV_HOME/$1" | |
python3 -m venv $VENV_HOME/$1 | |
echo "Activating $1" | |
venv $1 | |
fi | |
} | |
rmvenv() { | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide venv name" | |
else | |
rm -rf $VENV_HOME/$1 | |
fi | |
} | |
complete -C lsvenv venv | |
complete -C lsvenv rmvenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment