﻿---
title: Dotfile manager —— Dotbot
date: 2025-01-07
excerpt: A tool that bootstraps your dotfiles ⚡️
tags:
  - Dotfiles
  - Windows
  - Productivity
  - CLI
cover: https://assets.vluv.space/cover/Dev/Others/dotbot.webp
---

## Introduction

> [Dotbot](https://github.com/anishathalye/dotbot) makes installing your dotfiles as easy as `{sh} git clone \$url && cd dotfiles && ./install`, even on a freshly installed system!

不同程序的配置文件路径相对分散，以Windows为例，程序的配置文件路径可能是:

- `C:\Users\<username>\AppData\Roaming`
- `C:\Users\<username>\AppData\Local`
- `C:\Users\<username>\Documents`
- `C:\Users\<username>\.config`

配置文件的不集中，使得配置文件的管理&备份&恢复变得困难，Dotbot 是一个轻量级的 Python 程序，通过的json/yaml文件来管理dotfiles；与之类似的工具还有 yadm,gnu stow,dot drap etc.

## Usage

原理很简单，通过创建软链接(Symbolic Link)，将配置文件链接到指定的目录，这样就可以实现配置文件的集中管理

```yaml
- defaults:
    link:
      create: true
      relink: true
- clean:
    ["~", "~/.config", "~/AppData/Roaming", "~/AppData/Local", "~/Documents"]
- link:
    ~/.config/btop: tui_cli/btop
    ~/.config/fastfetch: tui_cli/fastfetch
    # ...
    D://envir_vars/scoop/apps/windows-terminal-preview/current/settings: terminal/windows-terminal
- shell: []
```
![dotbot_symlink](https://assets.vluv.space/dotbot_symlink.avif)

## Advantages

个人在配置文件仓库[Efterklang/dotfiles](https://github.com/Efterklang/dotfiles)，使用了 Dotbot 进行配置文件的管理，相比手动管理方便很多。如果经常对配置文件进行修改，那么使用 Dotbot 进行管理是一个不错的选择，支持 Windows & Linux & Mac。此外，Linux系统下还可以使用`GNU stow`进行配置文件的管理，原理类似。

过去使用 Onedrive/GitHub 进行配置文件的备份，有以下几方面限制:

|          | OneDrive                       | GitHub           | Dotbot                                                                 |
| -------- | ------------------------------ | ---------------- | ---------------------------------------------------------------------- |
| 备份修改 | 将配置文件从不同目录拷贝到云盘 | 与 OneDrive 类似 | 在统一目录下修改，修改后推送至远程仓库                                 |
| 配置迁移 | 下载云盘配置文件到 app 目录    | 与 OneDrive 类似 | `git clone` 仓库，执行 `install.ps1`                                   |
| 版本控制 | ⛔ (聊胜于无)                   | ✅                | ✅                                                                      |
| 扩展性   | ⛔                              | ⛔                | 支持通过 `git submodule` 安装插件，可以同步 scoop 应用、Windows 字体等 |

当然，这些限制在一定程度上可以通过其他方式解决，但毕竟都有现成的轮子了，不妨直接使用 🤓

## Reference

- [Plugins · anishathalye/dotbot Wiki](https://github.com/anishathalye/dotbot/wiki/Plugins)
- [Tips and Tricks · anishathalye/dotbot Wiki](https://github.com/anishathalye/dotbot/wiki/Tips-and-Tricks)
