最稳定方案有三种:①iCloud自动同步(苹果生态首选,零维护,延迟5–10分钟);②Git版本化同步(适合回滚、审计与协作);③符号链接+本地统一路径(隐私敏感或网络受限场景)。
让多台 mac 上的 iterm2 使用同一套配置,关键不是“复制”,而是让所有设备读取同一个配置源。iterm2 本身不提供云同步按钮,但 macos 的文件系统和 icloud、git 等机制可以无缝承接这个需求。目前最稳定、被广泛验证的有三种路径,按推荐顺序说明。
iCloud 自动同步(苹果生态用户首选)
适合日常开发、主力设备都在 Mac 上、追求零维护的用户。它不依赖命令行,修改后自动生效,延迟约 5–10 分钟。
- 确保所有 Mac 已登录同一 Apple ID,并在「系统设置 → Apple ID → iCloud」中开启了 iCloud Drive 同步
- 在每台设备上执行这条命令(注意空格和转义):
ln -sf ~/Library/Preferences/com.googlecode.iterm2.plist ~/Library/Mobile\ Documents/com~apple~CloudDocs/iTerm2/com.googlecode.iterm2.plist - 打开 iTerm2 → Preferences → General → Preferences,勾选「Load preferences from a custom folder」,路径填:
~/Library/Mobile Documents/com~apple~CloudDocs/iTerm2 - 重启 iTerm2,任意一台改一个 Profile 名字,稍等片刻,在另一台打开 Profiles 列表就能看到更新
Git 版本化同步(开发者长期维护推荐)
适合需要回滚、审计、多人协作或把终端配置当代码管理的用户。每次修改都有记录,分支清晰,不怕误操作。
- 新建本地仓库目录:
mkdir -p ~/git/configs/iterm2 && cd ~/git/configs/iterm2 - 导出当前配置:
defaults export com.googlecode.iterm2 com.googlecode.iterm2.plist - 初始化 Git 并推送到远程(如 GitHub、GitLab):
git init && git add . && git commit -m "init" && git remote add origin <your-repo-url> && git push -u origin main - 在新设备上拉取并加载:
cd ~/git/configs/iterm2 && git pull && defaults import com.googlecode.iterm2 com.googlecode.iterm2.plist - 重启 iTerm2 即可
符号链接 + 本地统一路径(兼顾隐私与可控)
不走云端、不用 Git,靠软链把配置指向你指定的本地目录(比如用 Syncthing、Resilio Sync 或 NAS 托管),适合对数据敏感或网络受限的环境。
- 在主设备创建集中配置目录:
mkdir -p ~/configs/iterm2 - 导出配置到该目录:
defaults export com.googlecode.iterm2 ~/configs/iterm2/com.googlecode.iterm2.plist - 创建软链覆盖原位置:
rm ~/Library/Preferences/com.googlecode.iterm2.plist
ln -sf ~/configs/iterm2/com.googlecode.iterm2.plist ~/Library/Preferences/com.googlecode.iterm2.plist - 在其他设备上也执行最后两步(先建好 ~/configs/iterm2,再拉取或同步该目录内容)
- iTerm2 无需额外设置,重启即读取新路径
三种方式都要求:配置文件必须脱离沙盒,且所有设备使用相同路径逻辑。选哪一种,取决于你更看重自动性、可追溯性,还是完全自主控制。


















