Skip to content

Instantly share code, notes, and snippets.

@lvdaqian
Last active December 14, 2025 16:37
Show Gist options
  • Select an option

  • Save lvdaqian/85c424101899b82d511d75a092f509c7 to your computer and use it in GitHub Desktop.

Select an option

Save lvdaqian/85c424101899b82d511d75a092f509c7 to your computer and use it in GitHub Desktop.
mac onboarding - phase 0 auth
#!/usr/bin/env bash
set -e
echo "🔐 Phase 0: Authorization & prerequisites"
# 1. 打开 App Store,登录 Apple ID
echo "👉 Opening App Store (please login Apple ID)..."
open -a "App Store"
# 2. 提示用户
cat <<EOF
==================================================
请手动完成以下事项(只需一次):
1️⃣ 登录 App Store
2️⃣ 搜索并点击「Xcode」→ 开始安装(不用等装完)
3️⃣ 如果弹权限提示,全部点「允许」
4️⃣ 不要关闭 App Store
完成后:
👉 直接运行 phase1-install.sh
==================================================
EOF
#!/usr/bin/env bash
set -e
log() { echo "👉 $1"; }
log "🚀 Phase 1: Automated install start"
# ===============================
# Homebrew
# ===============================
if ! command -v brew &>/dev/null; then
log "Installing Homebrew..."
NONINTERACTIVE=1 /bin/bash -c \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval "$(/opt/homebrew/bin/brew shellenv)"
brew update
# ===============================
# mas (App Store CLI)
# ===============================
brew install mas
# Xcode App Store ID
XCODE_APP_ID=497799835
# 如果 Xcode 还没在下,确保触发
if ! mas list | grep -q Xcode; then
log "Ensuring Xcode install is triggered..."
mas install $XCODE_APP_ID || true
fi
# ===============================
# Brewfile 并行安装
# ===============================
cat <<'EOF' > /tmp/Brewfile
# base
brew "git"
brew "zsh"
brew "wget"
brew "jq"
brew "fzf"
brew "ripgrep"
# dev
brew "node"
brew "deno"
brew "bun"
brew "pnpm"
brew "go"
brew "uv"
brew "docker"
brew "android-commandlinetools"
# apps
cask "iterm2"
cask "docker"
cask "visual-studio-code"
cask "feishu"
EOF
log "Installing brew packages (parallel with Xcode download)..."
brew bundle --file=/tmp/Brewfile
# ===============================
# 等待 Xcode 安装完成
# ===============================
log "Waiting for Xcode to finish installing..."
until [ -d "/Applications/Xcode.app" ]; do
sleep 30
done
log "Activating Xcode..."
sudo xcode-select -s /Applications/Xcode.app
sudo xcodebuild -license accept
# ===============================
# Shell
# ===============================
if [ ! -d "$HOME/.oh-my-zsh" ]; then
RUNZSH=no CHSH=no \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# ===============================
# Node ecosystem
# ===============================
corepack enable || true
pnpm setup || true
# ===============================
# Python (uv)
# ===============================
uv python install 3.12 || true
uv pip install --system pipx || true
# ===============================
# Android
# ===============================
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
yes | sdkmanager --licenses || true
sdkmanager "platform-tools" "platforms;android-34" || true
# ===============================
# Docker
# ===============================
open -a Docker || true
# ===============================
# Default shell
# ===============================
chsh -s /bin/zsh || true
log "✅ Phase 1 finished. Restart terminal when ready."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment