It appears (again) Linux already has something I wanted.

I manage dotfiles in git and wrote a script that checks recursively if file exists at $HOME and creates a symlink.

Turns out, stow already solves this.

My dotfile repo layout looks like this where dotfiles are encapsulated in root/:

1
2
3
4
├── root
│   ├── .aliases
│   ├── .config
│   │   ├── vimium-options.json

Command to stimulate setup. Remove --simulate to apply.

1
stow --simulate --dir="$(pwd)/root" --target="$HOME" .

Stow solves another problem for me – the undo.

1
stow --delete --dir="$(pwd)/root" --target="$HOME" .