Files
easyzsh/install_pyenv.sh
T
Frank Qing 34d11b5aa4 fix(shell): restore always-on PATH after macOS path_helper
path_helper runs after ~/.zshenv in login shells and puts Homebrew ahead of
fnm, pyenv, and ~/.local/bin. Re-source ~/.zshenv from ~/.zprofile and make
prepends idempotent so login and zsh -c resolve the same binaries.
2026-09-07 22:07:58 +08:00

29 lines
1.1 KiB
Bash
Executable File

#!/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).
# Login shells re-apply it via ~/.zprofile after macOS path_helper.
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"