Skip to main content

Command Palette

Search for a command to run...

Finally, I found the best way to keep dot files in sync

Updated
1 min read
Finally, I found the best way to keep dot files in sync
N
👋 Hi, I’m Nguyen, or you can call me Finn 💾 Vimmer ❤️ Gopher 📍I'm based in Da nang, Vietnam ⚙️ I love working with Go and Typescript ⚙️ I love both building distributed systems and the artistry of creating a single binary that efficiently uses minimal resources to accomplish as much as possible.

I was struggling to keep my dotfiles in GitHub in sync with the dot files in the $HOME directory. But now it is so smooth.

Cut to the chase, here is what I do:

  1. The $HOME folder will be the single source of truth. I keep all the original files here

  2. Use rsync to sync all the files from $HOME to dotfiles Github local repo

  3. Commit the files to the origin to backup.

You may have many files so you may have many rsync commands, let pack it into a bash function and add it to your ~/.zshrc

dotsync() {
  rsync -r ~/.config/nvim/* ~/projects/dotfiles/nvim
  rsync -r ~/.config/karabiner/* ~/projects/dotfiles/karabiner
  rsync -r ~/.config/kitty/* ~/projects/dotfiles/kitty
}

My dotfiles repo is public here https://github.com/finnng/dotfiles

There are a lot of benefits to this approach

  1. My dotfiles repo is pristine since the file itself is the single source of truth

  2. No more linking issues like sometimes you have to force linking with ln -fs

  3. Stress-free, no more file conflict, let the rsync command deal with it.

More from this blog

A pragmatic engineer blog, written by a human

18 posts

Original content. Real-world tradeoffs, lessons learned from production systems, and opinions shaped by experience, not just trends.

  • Practical over idealistic
  • Opinionated, but justified
  • Focused on what works rather than what’s fashionable