{"id":15646898,"url":"https://github.com/chaneyzorn/dotfiles","last_synced_at":"2025-07-25T12:35:07.556Z","repository":{"id":44353105,"uuid":"131723738","full_name":"chaneyzorn/dotfiles","owner":"chaneyzorn","description":"使用 GNU Stow 管理的 linux 配置文件.","archived":false,"fork":false,"pushed_at":"2025-06-22T04:59:33.000Z","size":859,"stargazers_count":50,"open_issues_count":0,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-22T05:28:23.689Z","etag":null,"topics":["dotfiles","gnu-stow","linux","lua","neovim","neovim-dotfiles","vimrc"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaneyzorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-01T14:38:17.000Z","updated_at":"2025-06-22T04:59:37.000Z","dependencies_parsed_at":"2023-01-27T14:46:35.668Z","dependency_job_id":"aa30c191-ebe8-4d06-bc6d-fc85510390f8","html_url":"https://github.com/chaneyzorn/dotfiles","commit_stats":{"total_commits":746,"total_committers":1,"mean_commits":746.0,"dds":0.0,"last_synced_commit":"c9978176f4bc0d23ba33a19ba511ed1ebf0e881f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chaneyzorn/dotfiles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaneyzorn%2Fdotfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaneyzorn%2Fdotfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaneyzorn%2Fdotfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaneyzorn%2Fdotfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaneyzorn","download_url":"https://codeload.github.com/chaneyzorn/dotfiles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaneyzorn%2Fdotfiles/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267007603,"owners_count":24020261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotfiles","gnu-stow","linux","lua","neovim","neovim-dotfiles","vimrc"],"created_at":"2024-10-03T12:15:39.466Z","updated_at":"2025-07-25T12:35:07.518Z","avatar_url":"https://github.com/chaneyzorn.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotfiles\n\n使用 [GNU Stow](https://www.gnu.org/software/stow/) 管理的 linux 配置文件.\n\nGnu Stow 使用两个文件夹来管理两个文件树之间的映射，分别是：\n\n- `stow dir`：默认为当前文件夹\n- `target dir`：默认为当前文件夹的父文件夹\n\n`stow dir`下每一个顶层的子文件夹都是一个单独的文件树,\n`target dir`下是多个这样的文件树在同一起始路径的层叠展开，后者的文件树使用**符号链接**指向前者的文件树。\n\n## 第一次收集配置文件\n\n第一次收集配置文件时，推荐使用`--adopt`选项转移配置文件。具体操作如下：\n\n1. 在家目录下创建`stow dir`， 比如命名为 dotfiles。\n\n2. 在`stow dir`下分门别类的创建好各类配置文件的文件夹，比如专门放置 bash 相关配置文件的文件夹。\n\n3. 在 bash 文件夹下创建对应的配置文件，文件内容为空即可，比如`.bashrc`，`.bash_profile`。\n\n4. 在`stow dir`下执行`stow --adopt bash`，这一命令分别对比`target dir`（也即是家目录）和 bash 目录的结构，\n   并将家目录下同树结构的文件采纳到`stow dir`下：将`.bashrc`移到bash目录覆盖掉对应的空配置文件，\n   并在家目录创建符号链接指向转移过来的配置文件。\n\n5. 重复上述 2-4 步，陆续添加其他文件夹和配置文件。\n\n收集到配置文件后，我们一般使用 git 来管理，这样可以方便的跟踪修改，也可以方便的拉取到另一台电脑上。\n实际上，我们上面使用的`--adopt` 命令可以结合 git 来方便的对比两台电脑间配置文件的不同。\n`--adopt`选项会处理 stow 遇到的冲突文件，并统一采用`target dir`下的文件**替换**`stow dir` 下的文件，\n当`stow dir`被 git 管理时，被替换的文件就可以方便的和仓库中的文件对比，方面你修改，采纳，或者删除。\n\n**注意**: `--adopt`选项会修改`stow dir`下的内容，非第一次收集配置文件，或者`stow dir`没有被版本控制软件管理前，请谨慎使用。\n\n## 将收集的配置文件应用到新的系统中\n\n将项目拉取到新的机器的家目录，切换到`stow dir`，执行`stow -S bash`可以将bash的配置文件展开到家目录下。\n你也可以使用多个组合命令：`stow -S pkg1 pkg2 -D pkg3 pkg4 -S pkg5 -R pkg6`\n\n- `-d` 指定 stow 文件夹\n- `-t` 指定 target 文件夹\n- `-D` 移除已创建的文件树\n- `-S` 创建指定的文件树\n- `-R` 移除并重新创建指定的文件树\n\n- `--ignore=regexp` 忽略`stow dir`下指定匹配模式的文件\n- `--defer=regexp` 跳过`target dir`下指定匹配模式的文件\n- `--override=regexp` 强制替换`target dir`下指定匹配模式的文件\n\n- `--no-folding` stow 默认创建最少的符号链接。这一选项会使 stow 逐一创建每一个文件的符号链接，而不是创建一整个文件夹的链接。\n- `--dotfiles` 在 stow dir 下的文件名如果有`dot-`前缀，在创建链接时，链接名字会替换为以`.`为前缀，\n  比如：`～/.zshrc -\u003e dotfiles/zsh/dot-zshrc`\n\nGNU Stow 不会对冲突的文件做任何处理，并中断所有操作，我没有找到一个快捷的覆盖已存在文件的选项，\n`-D` 和 `--override=regexp` 并不能对已存在的文件进行覆盖替换，除非它是符号链接或者文件夹并已经处于`stow dir`的管理之下。\n\n如果因为文件已经存在而发生了冲突，一个直接的办法是先删掉已存在的文件。而另一个方法则是结合使用 `--adopt`选项和 git。\n首先将已存在的配置文件全部采纳到 git 管理之下的 stow dir，然后选择性的采纳，修改，或舍弃，\n使用 git 的 commit 和 checkout，你可以方便的取舍冲突的配置文件。\n如果你知道stow更好的方法，请在 issue 中告诉我，谢谢～\n\n更多信息请参见 [GNU Stow 手册页](https://www.gnu.org/software/stow/manual/stow.html)\n\n## 软件包备份和恢复\n\n```sh\n# 获取当前系统中主动安装的包\npacman -Qqet \u003e pkglist.txt\n# 从列表文件安装软件包\npacman -S --needed - \u003c pkglist.txt\n# 如果其中包含AUR等外部包，需要过滤后再执行\npacman -S --needed $(comm -12 \u003c(pacman -Slq | sort) \u003c(sort pkglist.txt))\n# 移除没有列在文件中的包\npacman -Rsu $(comm -23 \u003c(pacman -Qq | sort) \u003c(sort pkglist.txt))\n```\n\n更多信息请参见 [pacman archlinux wiki](https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Install_packages_from_a_list)\n\n## License\n\n- MIT\n- CC BY-NC-SA 3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaneyzorn%2Fdotfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaneyzorn%2Fdotfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaneyzorn%2Fdotfiles/lists"}