5 ms·
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 https://github.co
by pprotas 2y ago
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 https://github.com/pprotas/dotfiles/blob/main/symlink.sh
That's it.
- PurpleRamen 2y agoThis 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.
- pprotas 2y agoYou 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.
- deleted 2y ago[deleted]
- jmondi 2y agoUsing 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).
- pprotas 2y agoAlthough 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.
- biftek 2y agoI use stow, which has some nice advantages vs managing symlinks yourself https://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html https://brandon.invergo.net/news/2012-05-26-using-gnu-stow-t...
- amarshall 2y agoSure, 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.
- tedmiston 2y agoSimilar 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
- pprotas 2y agoMy 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.
- fock 2y agoI 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.
- vbezhenar 2y agoYeah, same: https://github.com/vbezhenar/dotfiles/blob/main/ln-all https://github.com/vbezhenar/dotfiles/blob/main/ln-all No need for those complex software, just shell script is enough for me.
- tedmiston 2y agoI'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.
- deleted 2y ago[deleted]
- pprotas 2y agoWhat 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
- matheusmoreira 2y agoI think I'm the only person insane enough to use a makefile for this. https://github.com/matheusmoreira/.files/blob/master/GNUmakefile https://github.com/matheusmoreira/.files/blob/master/GNUmake... https://www.matheusmoreira.com/articles/managing-dotfiles-with-make https://www.matheusmoreira.com/articles/managing-dotfiles-wi... It even supports the XDG stuff as well as variables like GNUPGHOME.
- rcarmo 2y agoNope. There are at least two of us out there.