I accidentally nuked all of my dotfiles.
I decided to organize my dot files. I ran some rando’s script on Stackoverflow and it ended up overwriting my files…. The symlink was buggy 🙃📉
— Violet Guo (@YVioletGuo) December 2, 2021
Let me explain. I finally decided to back up my dotfiles properly. I found a seemingly straightforward Bash script that
- moves your current dotfiles from your root directory to a designated directory, aka your dotfile repo. Now this repo will become the source of truth. It is also tracked by Git.
- creates symlink at your root directory, which links to your dotfile repo.
What could possibly go wrong? This random script I found wasn’t idempotent. It failed but did not stop processing the rest of my files in the background. When I tried to run it again, it overwrote the links that were already linked with the link itself, and the originl dotfiles were lost.
Thankfully, I did stash my dotfiles somewhere. I proceeded with caution and there’re so many ways to go about dotfile mgmt.
- write your own shell script. I don’t trust myself at this point…
- use a git bare repo. TBH I really didn’t understand the whole rationale behind it.
- install someone’s pkg via a pkg mgmer. but what if the author abandons the project?
- finally, I found the dotbot
Dotbot
- it lives with your dotfile repo as a submodule. worst case scenario, the authoer abandons the project, and you just keep one working copy of it
- it’s deisgned to be idempotent. I value this design especially after my dotfile disaster.
- if you want a more detailed tutorial, try the official guide or this blog post
I finally have a pretty basic dotfile setup. It’s been years and I can’t believe no one taught this in university.
Speedround
Taken from one of the dotfile repos I found.
The frustration is real. End.