做一个 macOS 程序员一键安装脚本,用 Homebrew 自动安装常用工具,并附带终端环境配置,这样换电脑/重装系统时直接一行命令恢复开发环境。
1. 准备 Homebrew
如果你还没安装 Homebrew,先运行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. 创建一键安装脚本
新建一个脚本文件,比如 dev_setup.sh
:
nano dev_setup.sh
粘贴以下内容:
#!/bin/bash
echo "🚀 开始安装 macOS 开发者常用工具..."
# 确保 Homebrew 已更新
brew update
# --- 基础工具 ---
brew install git
brew install wget
brew install tree
brew install htop
brew install zsh
brew install starship # 终端美化
# --- 开发环境 ---
brew install --cask iterm2
brew install --cask warp
brew install --cask visual-studio-code
brew install --cask intellij-idea-ce
brew install --cask cursor
brew install --cask docker
# --- 终端增强 ---
brew install zsh-autosuggestions
brew install zsh-syntax-highlighting
brew install fzf
brew install thefuck
# --- API & 抓包 ---
brew install --cask postman
brew install --cask insomnia
brew install --cask proxyman
# --- 数据库 ---
brew install --cask tableplus
brew install --cask dbeaver-community
brew install --cask sequel-ace
# --- 效率工具 ---
brew install --cask raycast
brew install --cask rectangle
brew install --cask notion
brew install --cask obsidian
# --- 系统工具 ---
brew install --cask stats
brew install --cask appcleaner
# --- 设计相关 ---
brew install --cask figma
brew install --cask cleanshot
echo "✅ 所有工具安装完成!"
# --- 配置 Starship 终端美化 ---
if ! grep -q "eval \"\$(starship init zsh)\"" ~/.zshrc; then
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
fi
echo "🎨 已启用 Starship 终端美化,重新打开终端即可生效。"
3. 运行脚本
chmod +x dev_setup.sh ./dev_setup.sh
4. 脚本特点
一行命令安装全部工具
自动配置 Starship 美化终端
包含 常用 IDE、抓包、数据库客户端、效率工具
换电脑时只需:
curl -fsSL https://your-github-repo/dev_setup.sh | bash