Last active
September 4, 2023 14:57
-
-
Save robby-robby/29cd7f88ae9aa3da8130805e7b76d7b2 to your computer and use it in GitHub Desktop.
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
#uses venv and autoenv | |
#install them first! | |
#venv: https://docs.python.org/3/library/venv.html | |
#autoenv: https://github.com/hyperupcall/autoenv | |
#autoenv authorized envs are located in ~/.local/state/autoenv/authorized_list | |
function newpyenv() { | |
local DIR=$PWD | |
if [ $# -ne 0 ]; then | |
DIR="${PWD}/$1" | |
fi | |
mkdir -p "$DIR" | |
# git init "$DIR" | |
local ACT="${DIR}/bin/activate" | |
local ENV_FILE="${DIR}/.env" | |
echo "source ${ACT}" >"${ENV_FILE}" | |
cat <<EOF >"${DIR}/.gitignore" | |
bin | |
include | |
lib | |
.env | |
pyvenv.cfg | |
EOF | |
autoenv_authorize_env "${ENV_FILE}" | |
python3 -m venv $DIR | |
while [[ ! -f ${ACT} ]]; do | |
sleep 1 # Wait for 1 second before checking again | |
done | |
source "${ACT}" && | |
sleep 1 && | |
cd $DIR && | |
mkdir -p src && | |
git init . && | |
git add . && | |
git commit -m "newpyenv" && | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment