#!/bin/bash set -euo pipefail # Install pyenv (Python Version Manager) if it is not already installed if command -v pyenv &> /dev/null; then echo -e "pyenv is already installed\n" else echo -e "Installing pyenv (Python Version Manager)\n" # Using the official pyenv installer (https://github.com/pyenv/pyenv-installer) curl -fsSL https://pyenv.run | bash # Load pyenv for the remainder of this script export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init - bash)" command -v pyenv &> /dev/null fi # OPTIONAL: Install the latest stable version of Python # Uncomment the following line if you would like to automatically install it # pyenv install 3.12.0 && pyenv global 3.12.0 # Always-on fragment: ~/.config/zsh/pyenv.zsh (sourced from ~/.zshenv) curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s -- zsh/pyenv # Drop legacy interactive-only copy if present rm -f "$HOME/.config/zshrc/pyenv.zsh"