News for hackers. Stuff that matters.
Re:Using GNU Stow to manage your dotfiles (2012) by nickjj on Monday December 28, 2020 @06:45PM (#25564740)
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 across 2 systems (such as WSL 2 and Windows) where on a Windows box you consider certain Windows files dotfiles even though technically they exist elsewhere.

I've been managing my dotfiles like this for a few years and it seems to be working out well not just for myself but others who have want to use them either partially or in full. I open sourced them here: https://github.com/nickjj/dotfiles

I purposely broke up some of the commands because I know that not everyone will want a 100% replica of my dotfiles. Folks copy / paste only the commands they want.

Re:Using GNU Stow to manage your dotfiles (2012) by coldtea on Monday December 28, 2020 @07:32PM (#25565121)
>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?

Well, that's what you end up with. Stow just automates the "symlink those files part".

Re:Using GNU Stow to manage your dotfiles (2012) by kevin_thibedeau on Tuesday December 29, 2020 @03:44AM (#25567931)
More importantly, Stow can intelligently convert a symlinked directory into a real one when a second package wants to share it.
Re:Using GNU Stow to manage your dotfiles (2012) by rubyist5eva on Monday December 28, 2020 @07:26PM (#25565082)
Stow does this, it also has a --dotfiles switch so you can save your files as `dot-vimrc`, `dot-bashrc`, etc... so you don't have a bunch of hidden files in your repo
Re:Using GNU Stow to manage your dotfiles (2012) by bbkane on Tuesday December 29, 2020 @12:42AM (#25567089)
Too bad that's broken for directory names: https://github.com/aspiers/stow/issues/33
Re:Using GNU Stow to manage your dotfiles (2012) by adamspiers on Tuesday December 29, 2020 @07:01AM (#25568961)
Stow maintainer here. Thanks for the nudge on that, and apologies for not doing a better job. I hadn't noticed that this issue affecting so many users. I have some downtime in the coming week or two so will look at this.
Re:Using GNU Stow to manage your dotfiles (2012) by bbkane on Wednesday December 30, 2020 @08:44PM (#25588630)
Thank you! That fix will make my dotfiles repo look a lot nicer :)
Re:Using GNU Stow to manage your dotfiles (2012) by hxegon on Monday December 28, 2020 @06:57PM (#25564869)
That's pretty much what this is. I have a git repo with one dir for everything that needs configuration. Whenever I spin up a vps/vm or what have you, git clone dotfiles; cd dotfiles and stow what I'm using on that machine.

stow links based on the directory structure of the folder you're calling, so I don't have to worry about where things are, just stow fish; stow nvim

There's no symlink script or adapter script to work with stow, everything 'just works' for me.

Re:Using GNU Stow to manage your dotfiles (2012) by JoshTriplett on Monday December 28, 2020 @11:39PM (#25566786)
> 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.)

Re:Using GNU Stow to manage your dotfiles (2012) by yesbabyyes on Tuesday December 29, 2020 @02:34AM (#25567624)
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.

Re:Using GNU Stow to manage your dotfiles (2012) by scaladev on Tuesday December 29, 2020 @06:00AM (#25568661)
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) by StavrosK on Tuesday December 29, 2020 @06:07AM (#25568690)
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) by yesbabyyes on Tuesday December 29, 2020 @06:58AM (#25568944)
Brilliant, thanks!
Re:Using GNU Stow to manage your dotfiles (2012) by JoshTriplett on Tuesday December 29, 2020 @03:11PM (#25574256)
> 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.

I tend to always run "git status" before adding anything, which makes it fairly obvious what repository I'm in. (Or I'm working via fugitive in vim, which helps in the same way.)

Re:Using GNU Stow to manage your dotfiles (2012) by CUViper on Tuesday December 29, 2020 @03:31AM (#25567878)
I do it with a renamed `.git` and a bash alias `githome` that points `git` to the right place. This way it doesn't look like my home is a repo in normal use.
Re:Using GNU Stow to manage your dotfiles (2012) by tambourine_man on Monday December 28, 2020 @10:59PM (#25566571)
I still remember when git was the hot new version control system, so old fashioned sounds funny to me.
Re:Using GNU Stow to manage your dotfiles (2012) by tpoacher on Tuesday December 29, 2020 @09:52AM (#25570214)
I had the same reaction. Stow was first released (v>1.0) in 1996, git in 2013. Yet git is the old-fashioned choice? hahah.
Re:Using GNU Stow to manage your dotfiles (2012) by iamtedd on Wednesday December 30, 2020 @03:47AM (#25579875)
1.0 of Git was actually 2005.
Re:Using GNU Stow to manage your dotfiles (2012) by tpoacher on Wednesday December 30, 2020 @07:41PM (#25588185)
ah cool. i just had a look in the project's releases, 2013 was the first nonzero version they had listed there. I did wonder why they didn't list a v1.0 though.
Re:Using GNU Stow to manage your dotfiles (2012) by ironmagma on Monday December 28, 2020 @06:58PM (#25564882)
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 branch, there is no easy way to apply these changes to the home directory.

Re:Using GNU Stow to manage your dotfiles (2012) by ljm on Monday December 28, 2020 @08:26PM (#25565561)
If all your configs follow the XDG spec then you can turn ~/.config itself into the repo,and then use .gitignore as a whitelist:

    /*
    !git/config
    !tmux/tmux.conf
I do this and clone my repo directly to .config on a new machine. The only hold out was tmux but that's solved by installing or compiling one of the recent versions released this year (3b/3c). I'll still use manual symlinks for things like bash, but they're outliers.

Works great for me.

Re:Using GNU Stow to manage your dotfiles (2012) by midchildan on Tuesday December 29, 2020 @05:12AM (#25568420)
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) by cipherboy on Monday December 28, 2020 @07:24PM (#25565064)
> and delete it another way in another place (git rm).

I use `rm` all the time in git repos... Just `git add` when it is time to stage changes.

Re:Using GNU Stow to manage your dotfiles (2012) by ironmagma on Monday December 28, 2020 @07:26PM (#25565083)
Right, but when you unlink it from your home directory, the file still exists in the git repo. So there is a manual synchronization that must happen between the two directories.
Re:Using GNU Stow to manage your dotfiles (2012) by coldtea on Monday December 28, 2020 @07:33PM (#25565134)
>Right, but when you unlink it from your home directory, the file still exists in the git repo.

That's a feature.

Re:Using GNU Stow to manage your dotfiles (2012) by ironmagma on Monday December 28, 2020 @07:37PM (#25565179)
Not when you are looking for a workflow to make dealing with dotfiles faster and more painless. With the current (symlink based) setup, there is a hidden state you must hold in your head or else carefully inspect: the discrepancy between your git repo and your home directory. Maybe you forgot to link a dotfile, and that’s why your latest configuration doesn’t work. Ditto for unlinking a dotfile.
Re:Using GNU Stow to manage your dotfiles (2012) by Galanwe on Monday December 28, 2020 @08:32PM (#25565619)
Isn't that what -D, -S, and more simply -R do?

I did not use stow 2.x, but my understanding is that running stow -R will allow you to remove previous dangling symlinks (during the unstow) and add missing symlinks (during the restow). Effectively allowing you to only manage a single state: your git repository.

Re:Using GNU Stow to manage your dotfiles (2012) by kelnos on Tuesday December 29, 2020 @03:59AM (#25568007)
I delete dotfiles so infrequently (once a year?) that this just isn't a problem for me.

I also don't have all dotfiles under version control, just the ones I've essentially "built myself", so maybe that makes it easier.

Re:Using GNU Stow to manage your dotfiles (2012) by macintux on Monday December 28, 2020 @08:27PM (#25565574)
`git rm` will still leave the file available in the repo history, so violating the consistency seems more like a bug than a feature.
Re:Using GNU Stow to manage your dotfiles (2012) by coldtea on Tuesday December 29, 2020 @04:38AM (#25568206)
Still a feature. You might want to revert back to it. And history is history.
Re:Using GNU Stow to manage your dotfiles (2012) by kenrose on Monday December 28, 2020 @08:07PM (#25565410)
Call me old fashioned, but I remember using stow in 2003/2004, about a year before git existed.

Yes though, use a repo for sync, but stow takes care of at linking your dot files in the right place.

Re:Using GNU Stow to manage your dotfiles (2012) by devy on Tuesday December 29, 2020 @01:21AM (#25567287)
> 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?

Nothing wrong with tracking dotfiles with Git. It's probably the simplest and easiest approach without requiring any fancy tools other than Git. However, as mentioned in ArchLinux's wiki page, the disadvantage of Git approach is that "host-specific configuration generally requires merging changes into multiple branches."[1]

[1]: https://wiki.archlinux.org/index.php/Dotfiles#Tracking_dotfi...

Re:Using GNU Stow to manage your dotfiles (2012) by e40 on Tuesday December 29, 2020 @03:21AM (#25567822)
I've had my dotfiles in git for 7+ years. Work on Windows, Linux and macOS. Conditionalization in BASH is dead simple.

EDIT: 12+ years at work.

Re:Using GNU Stow to manage your dotfiles (2012) by sooheon on Tuesday December 29, 2020 @08:57AM (#25569740)
Yeah, it seems like keeping the cond inside the dotfiles, rather than in a dotfiles manager is the way to go.
Re:Using GNU Stow to manage your dotfiles (2012) by devy on Tuesday December 29, 2020 @12:43PM (#25572402)
Can you share some of your setup there to exemplify? Thanks.
Re:Using GNU Stow to manage your dotfiles (2012) by e40 on Tuesday December 29, 2020 @01:11PM (#25572805)
I use $(uname -s) (Cygwin required on Windows) and dispatch on that. There's really nothing more than that.
Re:Using GNU Stow to manage your dotfiles (2012) by db48x on Monday December 28, 2020 @07:13PM (#25564986)
> and then symlink those files to where they need to go?

This is exactly what Stow does.

Re:Using GNU Stow to manage your dotfiles (2012) by tmpxgdqrcKFuG on Monday December 28, 2020 @07:52PM (#25565302)
Yeah, I set it up with the Atlassian tutorial, https://www.atlassian.com/git/tutorials/dotfiles, and store it in a git repo in Keybase.io
Re:Using GNU Stow to manage your dotfiles (2012) by freeCandy on Tuesday December 29, 2020 @04:43AM (#25568243)
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) by mssundaram on Tuesday December 29, 2020 @03:37AM (#25567905)
> 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

Exactly! I do exactly that. I have an install.sh script that simply iterates over the files and directories in my dotfiles repo and does mkdir and ln

Re:Using GNU Stow to manage your dotfiles (2012) by michaelpb on Monday December 28, 2020 @08:41PM (#25565686)
That's what I do too. I even made a little Stow-inspired tool to help me, called "stowage", if you are curious: https://github.com/michaelpb/stowage
Re:Using GNU Stow to manage your dotfiles (2012) by gumby on Monday December 28, 2020 @11:34PM (#25566759)
Yeah, the command is literally (cd ~; ln -s source-location/{.,}[A-z]* .) which is a lot easier than installing all that stuff.
Re:Using GNU Stow to manage your dotfiles (2012) by LucasLarson on Wednesday December 30, 2020 @07:41PM (#25588187)
If we’re codegolfing dotfile setup, then really go crazy: `cd; ln -s source-location/{.,}[A-z]* .`