安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装版本管理器 fnm(Node.js)和 pyenv(Python)
brew install fnm
brew install pyenv
brew install zsh-autosuggestions
打开配置文件
touch ~/.zshrc
open ~/.zshrc
配置环境变量
将以下内容添加到 ~/.zshrc:
# fnm(Node.js 版本管理)
eval "$(fnm env --use-on-cd --shell zsh)"
# 自动读取 .nvmrc / .node-version 并切换版本
autoload -U add-zsh-hook
fnm_auto_switch() {
if [[ -f .nvmrc || -f .node-version ]]; then
fnm use --silent-if-unchanged
fi
}
add-zsh-hook chpwd fnm_auto_switch
# pyenv(Python 版本管理)
export PYENV_ROOT="$HOME/.pyenv"
[[ -d "$PYENV_ROOT/bin" ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# Python 命令别名
alias python='python3'
alias pip='pip3'
# 终端提示插件
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
重载配置
source ~/.zshrc
安装运行环境
# Node.js
fnm install 25
fnm default 25
# Python
pyenv install 3.14.10
pyenv global 3.14.10