mirror of
https://github.com/d0zingcat/dotfiles.git
synced 2026-05-13 23:16:44 +00:00
feat: 完善 dotfiles 迁移功能和备份脚本
主要改进: - .gitignore: 添加敏感数据排除规则和备份文件排除 - .zshrc: 添加工作函数标记注释 (# ==== WORK:) - git/config: 模板化占位符 (YOUR_NAME, YOUR_EMAIL, YOUR_SSH_SIGNING_KEY) - setup.sh: 增强备份功能,支持完整配置导出 - Brewfile 备份 - Git 配置摘要(脱敏) - SSH 公钥备份 - 1Password 配置文档 - VSCode 扩展列表 - 备份报告生成 - README.md: 重写为完整项目文档 - CHECKLIST.md: 新机器配置检查清单 - MIGRATION_GUIDE.md: 个人备份说明文档 - QUICKSTART.md: 3-5 分钟快速开始指南 使用方式: ./setup.sh backup # 备份当前配置 ./setup.sh full-recover # 新机器完整恢复
This commit is contained in:
320
MIGRATION_GUIDE.md
Normal file
320
MIGRATION_GUIDE.md
Normal file
@@ -0,0 +1,320 @@
|
||||
# Dotfiles 迁移指南
|
||||
|
||||
> 个人备份说明 - 用于新机器配置参考
|
||||
>
|
||||
> **创建时间**: 2026-03-04
|
||||
> **适用场景**: 离职后新公司机器配置
|
||||
|
||||
---
|
||||
|
||||
## 📋 目录
|
||||
|
||||
1. [备份内容](#备份内容)
|
||||
2. [不包含的内容](#不包含的内容)
|
||||
3. [新机器配置步骤](#新机器配置步骤)
|
||||
4. [常见问题](#常见问题)
|
||||
5. [个性化配置](#个性化配置)
|
||||
|
||||
---
|
||||
|
||||
## 📦 备份内容
|
||||
|
||||
### 已备份到 Git 仓库
|
||||
|
||||
| 文件/目录 | 说明 | 用途 |
|
||||
|-----------|------|------|
|
||||
| `.zshrc` | Shell 配置 | 60+ alias 和函数 |
|
||||
| `.tmux.conf` | Tmux 配置 | 终端复用 |
|
||||
| `git/config` | Git 配置模板 | 全局 Git 设置(占位符) |
|
||||
| `nvim/` | Neovim 配置 | 编辑器配置 |
|
||||
| `wezterm/` | WezTerm 配置 | 终端模拟器 |
|
||||
| `alacritty/` | Alacritty 配置 | 备用终端 |
|
||||
| `ghostty/` | Ghostty 配置 | 现代终端 |
|
||||
| `starship.toml` | Starship 配置 | Shell 提示符 |
|
||||
| `Brewfile` | Homebrew 包列表 | 所有工具和应用 |
|
||||
| `setup.sh` | 安装脚本 | 一键配置 |
|
||||
| `CHECKLIST.md` | 检查清单 | 配置验证 |
|
||||
| `QUICKSTART.md` | 快速开始 | 3-5 分钟配置 |
|
||||
| `README.md` | 完整文档 | 使用说明 |
|
||||
|
||||
### .gitignore 排除规则
|
||||
|
||||
以下敏感数据**不会被提交**,需要在新机器重新配置:
|
||||
|
||||
```
|
||||
.ssh/ # SSH 密钥
|
||||
.1password/ # 1Password 配置
|
||||
.kube/ # Kubernetes 配置
|
||||
*.env # 环境变量
|
||||
credentials.json # 凭据文件
|
||||
secrets.txt # 密钥文件
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚫 不包含的内容
|
||||
|
||||
以下数据需要**手动迁移**或**重新配置**:
|
||||
|
||||
### 需要重新生成的
|
||||
|
||||
- [ ] SSH 密钥对 (`~/.ssh/id_ed25519`)
|
||||
- [ ] GPG 密钥(如果使用)
|
||||
- [ ] Git 签名密钥
|
||||
|
||||
### 需要重新配置的
|
||||
|
||||
- [ ] Git 用户信息 (name, email)
|
||||
- [ ] 1Password SSH Agent
|
||||
- [ ] Kubeconfig (工作集群配置)
|
||||
- [ ] SSH config (如果有自定义主机)
|
||||
|
||||
### 需要单独备份的
|
||||
|
||||
- [ ] 浏览器书签
|
||||
- [ ] 应用许可证
|
||||
- [ ] 其他个人数据
|
||||
|
||||
---
|
||||
|
||||
## 🚀 新机器配置步骤
|
||||
|
||||
### 步骤 1: 克隆仓库
|
||||
|
||||
```bash
|
||||
git clone <your-repo-url> ~/.dotfiles
|
||||
cd ~/.dotfiles
|
||||
```
|
||||
|
||||
### 步骤 2: 运行一键恢复
|
||||
|
||||
```bash
|
||||
./setup.sh full-recover
|
||||
```
|
||||
|
||||
这将自动完成:
|
||||
- ✅ Xcode Command Line Tools 安装
|
||||
- ✅ Homebrew 安装
|
||||
- ✅ zsh antigen 安装
|
||||
- ✅ asdf 版本管理器安装
|
||||
- ✅ dotfiles 软链接创建
|
||||
- ✅ Git 基础配置
|
||||
- ✅ fzf 安装
|
||||
|
||||
### 步骤 3: 配置个人信息
|
||||
|
||||
#### Git 配置
|
||||
|
||||
```bash
|
||||
# 替换为你的真实信息
|
||||
git config --file ~/.gitconfig user.name "Your Name"
|
||||
git config --file ~/.gitconfig user.email "your@email.com"
|
||||
git config --file ~/.gitconfig user.signingkey "your-ssh-public-key"
|
||||
```
|
||||
|
||||
#### SSH 密钥生成
|
||||
|
||||
```bash
|
||||
# 生成新密钥
|
||||
ssh-keygen -t ed25519 -C "your@email.com"
|
||||
|
||||
# 查看公钥
|
||||
cat ~/.ssh/id_ed25519.pub
|
||||
|
||||
# 添加到 GitHub/GitLab
|
||||
# 1. 复制公钥: cat ~/.ssh/id_ed25519.pub | pbcopy
|
||||
# 2. 粘贴到 GitHub: Settings → SSH and GPG keys → New SSH key
|
||||
```
|
||||
|
||||
#### 1Password SSH Agent (如果使用)
|
||||
|
||||
```bash
|
||||
# 创建符号链接
|
||||
mkdir -p ~/.1password
|
||||
ln -s ~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock ~/.1password/agent.sock
|
||||
|
||||
# 添加 SSH 密钥到 1Password
|
||||
op ssh add ~/.ssh/id_ed25519
|
||||
```
|
||||
|
||||
### 步骤 4: 安装 Homebrew 包
|
||||
|
||||
```bash
|
||||
# 安装所有包和应用
|
||||
brew bundle install
|
||||
```
|
||||
|
||||
这会安装:
|
||||
- CLI 工具 (bat, ripgrep, fzf, lsd, difftastic)
|
||||
- 开发语言 (go, rustup, node, lua, bun, uv)
|
||||
- 数据库 (mysql, postgresql, redis)
|
||||
- Mac 应用 (1Password, Ghostty, Cursor, Obsidian, etc.)
|
||||
- VSCode 扩展
|
||||
|
||||
### 步骤 5: 验证安装
|
||||
|
||||
```bash
|
||||
# 运行检查脚本
|
||||
./setup.sh check
|
||||
```
|
||||
|
||||
预期输出:
|
||||
```
|
||||
Homebrew: ✓ installed
|
||||
Zsh: ✓ installed
|
||||
Neovim: ✓ installed
|
||||
Tmux: ✓ installed
|
||||
Antigen: ✓ installed
|
||||
```
|
||||
|
||||
### 步骤 6: 重启终端
|
||||
|
||||
```bash
|
||||
# 重启终端或重新加载配置
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ❓ 常见问题
|
||||
|
||||
### Q1: zsh 配置不生效
|
||||
|
||||
```bash
|
||||
# 重新加载配置
|
||||
source ~/.zshrc
|
||||
|
||||
# 或重启终端
|
||||
```
|
||||
|
||||
### Q2: Neovim 插件报错
|
||||
|
||||
```bash
|
||||
# 同步所有插件
|
||||
nvim --headless "+Lazy! sync" +qa
|
||||
|
||||
# 或打开 Neovim 后运行 :Lazy sync
|
||||
```
|
||||
|
||||
### Q3: Homebrew 权限问题
|
||||
|
||||
```bash
|
||||
# 修复权限
|
||||
sudo chown -R $(whoami) $(brew --prefix)
|
||||
```
|
||||
|
||||
### Q4: Git 签名失败
|
||||
|
||||
```bash
|
||||
# 检查 1Password SSH agent
|
||||
ls -la ~/.1password/agent.sock
|
||||
|
||||
# 列出已添加的密钥
|
||||
op ssh list
|
||||
|
||||
# 如果没有密钥,添加它
|
||||
op ssh add ~/.ssh/id_ed25519
|
||||
```
|
||||
|
||||
### Q5: Antigen 插件加载慢
|
||||
|
||||
```bash
|
||||
# 更新 antigen
|
||||
antigen selfupdate
|
||||
|
||||
# 更新所有插件
|
||||
antigen update
|
||||
|
||||
# 清理缓存
|
||||
antigen reset
|
||||
antigen apply
|
||||
```
|
||||
|
||||
### Q6: Tmux 插件未安装
|
||||
|
||||
```bash
|
||||
# 在 tmux 中按下 Ctrl-a + I (大写的 i)
|
||||
# 这会安装 TPM 插件
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ 个性化配置
|
||||
|
||||
### 修改 Git 配置
|
||||
|
||||
编辑 `~/.dotfiles/git/config` 或直接运行:
|
||||
|
||||
```bash
|
||||
git config --global user.name "Your Name"
|
||||
git config --global user.email "your@email.com"
|
||||
```
|
||||
|
||||
### 添加新 alias
|
||||
|
||||
编辑 `~/.dotfiles/.zshrc`,在 alias 区域添加:
|
||||
|
||||
```zsh
|
||||
alias myalias='command'
|
||||
```
|
||||
|
||||
然后运行 `source ~/.zshrc`
|
||||
|
||||
### 添加 Homebrew 包
|
||||
|
||||
编辑 `~/.dotfiles/Brewfile`,添加:
|
||||
|
||||
```ruby
|
||||
brew "package-name"
|
||||
cask "app-name"
|
||||
```
|
||||
|
||||
然后运行 `brew bundle install`
|
||||
|
||||
### 修改 Neovim 配置
|
||||
|
||||
编辑 `~/.dotfiles/nvim/lua/plugins/` 下的文件。
|
||||
|
||||
---
|
||||
|
||||
## 📞 需要帮助?
|
||||
|
||||
- 查看 [README.md](./README.md) 获取完整文档
|
||||
- 查看 [CHECKLIST.md](./CHECKLIST.md) 获取检查清单
|
||||
- 查看 [QUICKSTART.md](./QUICKSTART.md) 获取快速开始
|
||||
- 运行 `./setup.sh help` 查看命令说明
|
||||
|
||||
---
|
||||
|
||||
## 📝 配置记录
|
||||
|
||||
### 当前配置
|
||||
|
||||
| 项目 | 值 |
|
||||
|------|-----|
|
||||
| Shell | zsh + antigen + oh-my-zsh |
|
||||
| 编辑器 | Neovim (lazy.nvim) |
|
||||
| 终端 | WezTerm / Ghostty / Alacritty |
|
||||
| 终端复用 | Tmux (TPM) |
|
||||
| 提示符 | Starship |
|
||||
| 版本管理 | asdf |
|
||||
|
||||
### 主要工具
|
||||
|
||||
- **语言**: Go, Rust, Node.js, Python, Lua, Bun
|
||||
- **K8s**: kubectl, k9s, helm, kubectx
|
||||
- **数据库**: MySQL, PostgreSQL, Redis
|
||||
- **Git**: SSH 签名 (1Password)
|
||||
|
||||
---
|
||||
|
||||
## 🔐 安全提醒
|
||||
|
||||
1. **不要提交敏感数据** - 所有敏感路径已在 `.gitignore` 中排除
|
||||
2. **新机器重新生成密钥** - SSH、GPG 等密钥应该在新机器重新生成
|
||||
3. **移除旧机器授权** - 离职前移除旧机器的 GitHub、1Password 授权
|
||||
4. **更新密码** - 如果可能,更新重要账户的密码
|
||||
|
||||
---
|
||||
|
||||
**祝新工作顺利!** 🎉
|
||||
Reference in New Issue
Block a user