Skip to content

Instantly share code, notes, and snippets.

@mcking-07
Created April 21, 2024 16:28
Show Gist options
  • Save mcking-07/0220649ee75d025fa457c1a7bb76096b to your computer and use it in GitHub Desktop.
Save mcking-07/0220649ee75d025fa457c1a7bb76096b to your computer and use it in GitHub Desktop.
python env manager
pload() {
local ENV_DIR=".pyenv"
local SCRIPT_PATH="$ENV_DIR/bin/activate"
if [ -d "$ENV_DIR" ] && [ -f "$SCRIPT_PATH" ]; then
source "$SCRIPT_PATH"
else
read -p "environment not found. create one? (Y|n) " choice
case $choice in
Y|y|"")
python3 -m venv "$ENV_DIR" && source "$SCRIPT_PATH" || echo "environment setup failed." ;;
N|n)
echo "cancelled!" ;;
*)
echo "unrecognized option." ;;
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment