Created
November 9, 2021 12:55
-
-
Save danielk333/4f94152488f4db5449055ad1a2490799 to your computer and use it in GitHub Desktop.
Venv tools in bash
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
activate () { | |
source ~/venvs/$1/bin/activate | |
} | |
lazyvenv () { | |
name=$(basename $(pwd)) | |
if [ -d ~/venvs/$name ] | |
then | |
activate $name | |
else | |
echo "No venv found: creating venv" | |
venv | |
if [ -d ~/venvs/$name ] | |
then | |
activate $name | |
fi | |
fi | |
} | |
venv () { | |
if [ -z $1 ] | |
then | |
venv_target=$(basename $(pwd)) | |
else | |
venv_target=$1 | |
fi | |
echo "New venv target=$venv_target" | |
if [ -d ~/venvs/$venv_target ] | |
then | |
echo "Folder '~/venvs/$venv_target' exists, choose a different name for new venv" | |
else | |
python -m venv ~/venvs/$venv_target | |
echo "Created virtualenv $venv_target" | |
fi | |
} | |
venvs () { | |
for dr in ~/venvs/* | |
do | |
echo "$dr | python $(cat $dr/pyvenv.cfg | grep version)" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment