Live data from Hacker News

Using GNU Stow to manage your dotfiles (2012)

brandon.invergo.net

91–100 of 116 posts

Re: Using GNU Stow to manage your dotfiles (2012)

#91
post #43

Earlier quoted context omitted.

> Right, but when you unlink it from your home directory, the file still exists in the git repo. That's a feature.

`git rm` will still leave the file available in the repo history, so violating the consistency seems more like a bug than a feature.

Still a feature. You might want to revert back to it. And history is history.

Re: Using GNU Stow to manage your dotfiles (2012)

#92
post #29

Call me old fashioned but what's wrong with having a regular git repo anywhere you want with all of your dotfiles and them symlink those files to where they need to go? If you wanted to you could && a few symlinks and other commands into 1 copy / paste'able command to get up and running really quickly. It's also painless to manage secrets by sourcing in optional files. It also works nicely when you want files living…

I've been using bashdot(https://github.com/bashdot/bashdot) does exactly this. It's a simple bash script that sets up symlinks for a given directory. It can also switch symlinks to different directories, so you could use that as swappable profiles.

Re: Using GNU Stow to manage your dotfiles (2012)

#93
post #56

You don't need symlinks, setup scripts, etc. Try this: 1. Bare git repo in your home directory ($HOME/.files) 2. Alias for prefixing git commands ("env GIT_WORK_TREE=$HOME GIT_DIR=$HOME/.files") 3. Strict .gitignore file (that ignores all files by default) Simple to add files: `h git add .vimrc` Have this set up for myself. Works great https://github.com/tmm/dotfiles

I've been doing something similar.

Basically adding a alias to my zshrc, that runs: `git --git-dir=$HOME/dotfiles --work-tree=$HOME`.

And then set status.showUntrackedFiles to no.

See: https://github.com/sp1ritCS/dotfiles

I've got this idea from the following blogpost: https://news.opensuse.org/2020/03/27/Manage-dotfiles-with-Gi...

Re: Using GNU Stow to manage your dotfiles (2012)

#94
post #29

Call me old fashioned but what's wrong with having a regular git repo anywhere you want with all of your dotfiles and them symlink those files to where they need to go? If you wanted to you could && a few symlinks and other commands into 1 copy / paste'able command to get up and running really quickly. It's also painless to manage secrets by sourcing in optional files. It also works nicely when you want files living…

Not sure if Stow fixes these, but here are some problems I've had with that setup: 1. If you want to delete a file, you have to delete it (rm) in one place and delete it another way in another place (git rm). 2. Adding a new file in-situ (in the home directory) requires some finessing to get it back into the git repo and symlinked properly. 3. No easy way to apply a rename operation. 4. After changing the checked out…

I believe Stow can fix everything except #2 [1], although I haven't actually used it before. But it's also easy to create your own "garbage collector" that cleans up dangling symlinks in your home directory.

All you need to do is to keep track of symlinks you've installed with your setup script. This can be done by creating a symlink to the symlink you've installed, which acts as a "GC root." The next time you run the setup script, it would check those "GC roots" to see if they point to a valid file and remove any dangling symlinks.

This is the approach I take for my own dotfiles. I seriously considered using Stow or the bare git approach before, but I decided against it because setting up my dotfiles involved more than just installing symlinks. I had to be able to download files (e.g., vim-plug), clone git repositories, change file permissions, and maintain files that's not meant to be linked into the home directory. I found the flexibility of a custom shell script most fit for my needs.

[1]: The "Deleting Packages" section in https://linux.die.net/man/8/stow

Re: Using GNU Stow to manage your dotfiles (2012)

#95

I’ve been using stow to manage my dotfiles for a long time, works very well. Recently I’ve moved to NixOS and have been considering trying out Nix’s home-manager (mostly just out of curiosity - I’m perfectly happy with stow). If anyone has tried both stow and home-manager, I’d be interested to know your thoughts on how they compare.

home-manager is how I'm getting into nix. Having generations for my dotfiles is very appealing. Maybe I never really got the hang of stow, but I would also get bitten by it when I would rearrange my dotfiles, which would leave dead symlinks around. Perhaps this is what "unstowing" is for?

Re: Using GNU Stow to manage your dotfiles (2012)

#97

Earlier quoted context omitted.

> Call me old fashioned but what's wrong with having a regular git repo anywhere you want with all of your dotfiles and them symlink those files to where they need to go? I prefer to skip the symlinks, and just directly use the git repository as my home directory. (I have a sizable .gitignore for things I don't want to track.)

I do the same, but I just have a single '*' in my .gitignore. The only drawback to the homedir-as-git-repo approach I've found is that you're always in a git repo, so you have to be careful not adding stuff which was really supposed to go in another repo.

Here's a better solution.

https://www.atlassian.com/git/tutorials/dotfiles

TL;DR:

  alias dotfiles='/usr/bin/git --git-dir=$HOME/src/dotfiles --work-tree=$HOME'
  dotfiles add
  dotfiles commit
  ...

Re: Using GNU Stow to manage your dotfiles (2012)

#98

Earlier quoted context omitted.

I do the same, but I just have a single '*' in my .gitignore. The only drawback to the homedir-as-git-repo approach I've found is that you're always in a git repo, so you have to be careful not adding stuff which was really supposed to go in another repo.

Here's a better solution. https://www.atlassian.com/git/tutorials/dotfiles TL;DR: alias dotfiles='/usr/bin/git --git-dir=$HOME/src/dotfiles --work-tree=$HOME' dotfiles add dotfiles commit ...

I really like that solution, thanks. It also means I can easily move my current git dir to the new place and still have everything work.

Does anyone know if syncing a git repo over Syncthing (or similar) is a good idea or whether there are likely to be conflicts? I don't know if git names its files such that conflicts aren't possible.

Re: Using GNU Stow to manage your dotfiles (2012)

#99
post #16

I originally went with the bare git repo technique, but found myself not liking how to store multiple computer's dotfiles in a single repo. I ended up switching to https://www.chezmoi.io/ , after learning about it here on HN.

Absolutely love Chezmoi.

Its a small, statically linked binary which is easy to install and the templating feature is really useful.

Re: Using GNU Stow to manage your dotfiles (2012)

#100

Earlier quoted context omitted.

I do the same, but I just have a single '*' in my .gitignore. The only drawback to the homedir-as-git-repo approach I've found is that you're always in a git repo, so you have to be careful not adding stuff which was really supposed to go in another repo.

Here's a better solution. https://www.atlassian.com/git/tutorials/dotfiles TL;DR: alias dotfiles='/usr/bin/git --git-dir=$HOME/src/dotfiles --work-tree=$HOME' dotfiles add dotfiles commit ...

Brilliant, thanks!
Post reply on HN