macOS 命令速查
安装 Homebrew
Section titled “安装 Homebrew”新机第一件事。官方安装脚本会自行处理 Command Line Tools 依赖。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Apple Silicon 上 Homebrew 装在 /opt/homebrew,需要把它写进当前 shell 的环境:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofileeval "$(/opt/homebrew/bin/brew shellenv)"用 Brewfile 批量装机
Section titled “用 Brewfile 批量装机”把已装的东西导出成清单,换机时一条命令还原,比逐个 brew install 可靠得多。
# Export what is currently installedbrew bundle dump --describe --force --file=~/Brewfile
# Restore on a new machinebrew bundle install --file=~/Brewfile
# Remove anything not listed in the Brewfilebrew bundle cleanup --force --file=~/Brewfile生成 SSH 密钥
Section titled “生成 SSH 密钥”默认用 ed25519,比 RSA 更短也更快。注释里写清楚这把钥匙属于哪台机器。
ssh-keygen -t ed25519 -C "laptop-$(date +%Y%m)" -f ~/.ssh/id_ed25519
# Load it into the agent and the macOS keychainssh-add --apple-use-keychain ~/.ssh/id_ed25519
# Copy the public key to the clipboardpbcopy < ~/.ssh/id_ed25519.pub启动开发服务器之前先确认端口是空的。
# Who is listening on port 4321lsof -nP -iTCP:4321 -sTCP:LISTEN
# Kill it once you are surekill -15 <PID># Update formulae and upgrade everythingbrew update && brew upgrade
# Reclaim disk space from old versionsbrew cleanup --prune=all
# Check for problems before filing a bugbrew doctor