Last active
December 12, 2025 03:10
-
-
Save burugo/2553dbe051c0f6f0771c07dcf9653f49 to your computer and use it in GitHub Desktop.
新 Mac 执行: • 检测 iCloud 是否启用 • 自动创建 dotfiles 结构 • 自动备份旧 config • 自动创建 symlink • 自动验证路径 • 自动 reload Ghostty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| ICLOUD_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs" | |
| DST_DIR="$ICLOUD_DIR/dotfiles/ghostty" | |
| SRC_DIR="$HOME/Library/Application Support/com.mitchellh.ghostty" | |
| echo "🔍 Checking iCloud Drive…" | |
| if [ ! -d "$ICLOUD_DIR" ]; then | |
| echo "❌ iCloud Drive not found at:" | |
| echo " $ICLOUD_DIR" | |
| echo "➡ 请先确保已登录 iCloud 并启用 iCloud Drive。" | |
| exit 1 | |
| fi | |
| echo "📁 Ensuring iCloud ghostty directory exists..." | |
| mkdir -p "$DST_DIR" | |
| #-------------------------------------------- | |
| # STEP 1 — If local ghostty config exists, move it to iCloud | |
| #-------------------------------------------- | |
| if [ -d "$SRC_DIR" ] && [ ! -L "$SRC_DIR" ]; then | |
| echo "📦 Found existing local ghostty directory." | |
| echo "➡ Moving it to iCloud (backup will be kept)…" | |
| # Backup local dir just in case | |
| ts=$(date +"%Y%m%d-%H%M%S") | |
| BACKUP="$SRC_DIR.backup-$ts" | |
| echo "🗄 Backing up local ghostty to:" | |
| echo " $BACKUP" | |
| mv "$SRC_DIR" "$BACKUP" | |
| echo "📤 Moving backup → iCloud directory…" | |
| mv "$BACKUP" "$DST_DIR" | |
| fi | |
| #-------------------------------------------- | |
| # STEP 2 — Create symlink if not already | |
| #-------------------------------------------- | |
| if [ -L "$SRC_DIR" ]; then | |
| echo "✔ Symlink already exists. Nothing to do." | |
| else | |
| echo "🔗 Creating symlink:" | |
| echo " $SRC_DIR → $DST_DIR" | |
| ln -s "$DST_DIR" "$SRC_DIR" | |
| fi | |
| #-------------------------------------------- | |
| # STEP 3 — Verification | |
| #-------------------------------------------- | |
| echo "🔍 Verifying symlink…" | |
| if [ -L "$SRC_DIR" ]; then | |
| TARGET=$(readlink "$SRC_DIR") | |
| echo "🎉 Success!" | |
| echo "Ghostty is now synced via iCloud:" | |
| echo "📌 $SRC_DIR → $TARGET" | |
| else | |
| echo "❌ Symlink creation failed." | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "✨ 完成!Ghostty 全目录(主题、配置、快捷键等)已经自动通过 iCloud 同步。" | |
| echo "🖥 多台 Mac 上运行此脚本即可共享同一套 Ghostty 配置。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment