Preferences

All you need is a symlink script that symlinks files in ~ to ~/path/to/your/dotfiles

https://github.com/pprotas/dotfiles/blob/main/symlink.sh

That's it.


Using the GNU stow utility makes this super easy. It even has a --dotfiles flag so you can author your dotfiles as dot-zshrc and when the utility symlinks it, it will be .zshrc. Makes it nice so your source files are not hidden but the actual dotfiles are (as expected).
Although GNU stow is very interesting, I like this simple script because it has no external dependencies. Stow is not available on macos by default, for example.
It is available though in every package manager for macOS except the App Store, and any user of a script like this on macOS is probably also using Homebrew, macports, Nix, or srcpkg.
I got mine from brew. Like 90% of my userland, really.
This will not handle cases other targets than $HOME. The automatic deletion seems also very risky. In my own script, I move all pre-existing targets to a separate directory, so I can check later.
You can set the source and target directories to whatever you'd like, this is just what I need for my own use. The automatic deletion is for directories, to prevent recursive symlinks. Of course, you can program your own however you wish, maybe add a confirmation step before removing and/or create a backup beforehand.
I think I'm the only person insane enough to use a makefile for this.

https://github.com/matheusmoreira/.files/blob/master/GNUmake...

https://www.matheusmoreira.com/articles/managing-dotfiles-wi...

It even supports the XDG stuff as well as variables like GNUPGHOME.

Nope. There are at least two of us out there.
I use stow, which has some nice advantages vs managing symlinks yourself

https://brandon.invergo.net/news/2012-05-26-using-gnu-stow-t...

I made it Python, added a simple json-config and mustache-templating. Very portable (where symlinks are), very flexible (also used it for termux for a bit) and very simple.
Sure, maybe. Though eventually one may find lots of edge cases. What about files in the root that get deleted? What about programs that put wanted state within config dirs? What about programs that ignore symlinked files? What about when you’re hacking on your dotfiles and break everything because the active config is the config being edited? What about when you need to vary based on system? What about…

I mean, yea, if it works for you, great! But all of the above are problems I did have. I grew a custom install script for years. Now I use Home Manager and the impermanence module.

My approach to coding is to tackle these types of problems once they occur, instead of thinking "What about...", "What if...". I don't have these problems you're describing, so the script works great.
Similar experience here, like: What about when your editor is set to auto save when unfocusing a tab or window and saves while you were mid-edit on your dotfiles and now every new shell is crashing? etc etc
Yeah, same: https://github.com/vbezhenar/dotfiles/blob/main/ln-all

No need for those complex software, just shell script is enough for me.

I'm sorry, but running `rm -rf ...` in a script against $HOME is a bit too reckless for me.

Maybe you haven't lost data from this yet, but this is where Chezmoi has nice guardrails and protects against, e.g., modifications or additions accidentally being made to $HOME instead of the dotfiles dir, which look like they would be silently blown out by your current process.

Just my 2¢ from someone who used to do it this way and lost data because of it.

What do you think is the risk here? I don’t see a code path to remove my home dir in the script

EDIT: Unless I have a dir called "*" in my dotfiles, but at that point I deserve to have my home dir removed :P ZSH also asks for confirmation first

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal