在 iTerm2 中,配色(Color Scheme)與主題(Profile 設定)可以匯出成設定檔,方便在不同設備間同步使用,也適合團隊統一開發環境。以下是完整教學與範例說明。
🎨 一、匯出 iTerm2 配色與主題檔案(.itermcolors & profile)
✅ 方法 1:匯出 .itermcolors 配色檔
步驟:
- 打開 iTerm2 →
iTerm2菜單 →Preferences(快捷鍵:⌘ + ,) - 點選上方「Profiles」→ 選擇你想匯出的 Profile(例如:Default)
- 點選右下角「Color」分頁
- 點擊「Color Presets」下拉選單 → 選擇你當前使用的配色
- 若想匯出該配色:
- iTerm2 原生沒有「匯出」按鈕,但你可以:
- 手動下載
.itermcolors(見下方資源) - 或從原始 iTerm2 設定檔中提取(進階)
- 手動下載
- iTerm2 原生沒有「匯出」按鈕,但你可以:
✅ 方法 2:備份整個 iTerm2 設定(包含 Profile 與主題)
這是最實用的方法,尤其是你想保留所有視窗外觀、字體、顏色、快捷鍵等設定。
匯出設定步驟:
- 開啟 iTerm2 →
Preferences(⌘ + ,) - 點選最右側分頁「General」
- 在底部
Preferences區域找到:☑ Load preferences from a custom folder or URL
🔘 Save changes to folder when iTerm2 quits - ✅ 勾選上面兩個選項,並選擇一個資料夾(建議用 Git 管理的 dotfiles 資料夾)
- 你會看到該資料夾下生成一個檔案:
👉com.googlecode.iterm2.plist
匯出完成後:
你只要複製這個 .plist 檔案到其他電腦,再到 iTerm2 → Preferences → General → 指向該 .plist 所在資料夾,即可載入所有設定。
🧪 可選:使用 CLI 匯出與還原設定
匯出:
defaults export com.googlecode.iterm2 ~/Desktop/iterm2_backup.plist
還原:
defaults import com.googlecode.iterm2 ~/Desktop/iterm2_backup.plist
killall cfprefsd
注意:還原會覆蓋目前設定,請先備份!
🌈 配色資源 .itermcolors(可下載匯入)
你可以從這些地方下載 .itermcolors 配色檔:
- 🔗 官方配色倉庫:https://github.com/mbadolato/iTerm2-Color-Schemes
- ✅ 匯入方法:
Preferences→Profiles→Colors- 點選
Color Presets→Import... - 選取下載的
.itermcolors檔案 - 然後套用即可
📁 建議目錄結構(用於同步/版本控管)
~/dotfiles/
├── iterm2/
│ ├── itermcolors/
│ │ └── Dracula.itermcolors
│ └── com.googlecode.iterm2.plist
└── install.sh # 一鍵匯入 script(可選)
🚀 Bonus:快速還原主題與設定(可用於新機)
# 建立資料夾並複製設定
mkdir -p ~/dotfiles/iterm2
cp com.googlecode.iterm2.plist ~/dotfiles/iterm2/
# 在新機 iTerm2 中設定 preferences 路徑:
# Preferences > General > Load preferences from custom folder
# 指向 ~/dotfiles/iterm2