我的 macOS 开发环境配置
每次换新电脑都要重新折腾一遍环境,干脆记录下来,下次照着做就好。
包管理:Homebrew
几乎所有命令行工具都通过 Homebrew 安装:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
常用软件一次装好:
brew install git node pnpm ripgrep fd fzf bat eza zoxide
Shell
Zsh + Starship
macOS 默认就是 zsh,提示符我用 Starship,轻量又好看:
brew install starship
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
常用别名
alias ls="eza --icons"
alias ll="eza -la --icons --git"
alias cat="bat --paging=never"
alias gs="git status -sb"
eval "$(zoxide init zsh)" # 用 z 代替 cd
Git 配置
[user]
name = Your Name
email = you@example.com
[init]
defaultBranch = main
[pull]
rebase = true
[core]
pager = delta
Node.js
用 pnpm 管理依赖,速度快、省磁盘:
corepack enable
pnpm --version
小结
工具只是手段,顺手才是目的。配置不必一步到位,用着不舒服的时候再调整就好。