给 Web 开发者看的 macOS 新机设置指南

550 阅读1分钟

以下内容假使读者已具备正确上网技能,如果不能正确上网部分链接会无法打开。

1. 安装 Homebrew

Homebrew 是包管理工具,也可安装管理 GUI 软件,第一件事就是打开 term.app 安装 Homebrew,安装命令直接复制自官网

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 通过 Homebrew 安装 iTerm2

iTerm2 相比自带的终端拥有更多功能以及更好用的分屏

brew install iterm2

另一个终端选择 Ghostty

2.1 配置 iTerm2

配置支持 ⌘ ← , ⌘ →, ⌥ ←, ⌥ → 快捷键在终端中快速调整单词

NLIVi.gif

3. 安装 Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

4. 配置 .zshrc

4.1 增加 zsh 插件

编辑 ~/.zshrc

vi ~/.zshrc

修改 plugins 部分增加插件 z, zsh-autosuggestions, zsh-syntax-highlighting

plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)

其中 zsh-autosuggestions, zsh-syntax-highlighting 需要用以下命令下载

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

4.2 去除用户名显示

编辑 ~/.zshrc

vi ~/.zshrc

加入以下内容

# User configuration
export DEFAULT_USER="$(whoami)"

4.3 增加快捷命令

编辑 ~/.zshrc

vi ~/.zshrc

加入以下内容

alias proxy='export https_proxy=http://127.0.0.1:8888;export http_proxy=http://127.0.0.1:8888;export all_proxy=socks5://127.0.0.1:8889'
alias unproxy='unset https_proxy http_proxy all_proxy'

alias d='docker'
alias dc='docker-compose'
alias nr='npm run'
alias c='cursor'

注:当前更推荐开启 tun 模式,可以不需要这个快捷命令

4.4 安装 Powerline 字体(可选)

如果额外设置了主题带有特殊字体可能需要再安装 Powerline 字体

cd ~/Developer

git clone https://github.com/powerline/fonts.git  # 将 Powerline 字体文件下载到「下载」文件夹中

cd fonts && ./install.sh  # 安装所有 Powerline 字体

安装好之后按 ⌘, 打开终端偏好设置,在描述文件 > 文本中更改字体。

5. 安装 fnm 和 Node.js

通过 fnm 安装 Node.js 可以方便的进行版本切换

# Download and install fnm:
curl -o- https://fnm.vercel.app/install | bash
# Download and install Node.js:
fnm install 24
# Verify the Node.js version:
node -v # Should print "v24.14.0".
# Verify npm version:
npm -v # Should print "11.9.0".
# Add sheel setup to `.zshrc` profile:
echo 'eval "$(fnm env --use-on-cd --shell zsh)"' >> ~/.zshrc

6. 安装一些 Node.js 全局依赖

npm i -g serve @vue/cli

7. 使用 HomeBrew 安装需要的软件

这部分大家可以自己选择安装,安装自己需要的软件即可

brew install nginx thefuck mc libpq gh
brew install alfred caffeine google-chrome notion teamviewer charles obs visual-studio-code firefox istat-menus postman vlc gas-mask macdown spotify reactangle localsend sublime-merge sublime-text microsoft-edge dbeaver-community docker-desktop

8. AI

brew install cursor claude-code codex codex-app gemini-cli antigravity cc-switch agent-browser

agent-browser install  # Download Chrome from Chrome for Testing (first time only)
npx skills add vercel-labs/agent-skills
npx skills add vercel-labs/agent-browser
npx add-mcp -g next-devtools-mcp@latest chrome-devtools-mcp@latest @upstash/context7-mcp @playwright/mcp@latest

Reference