
Managing dotfiles with GNU Stow - pmoriarty
https://taihen.org/managing-dotfiles-with-gnu-stow/
======
gioele
And, in general, it would be better if there were fewer dotfiles in $HOME.

Please application developers, follow the XDG Base Directory spec (or the
equivalent in Windows and Mac OS X).

See [https://specifications.freedesktop.org/basedir-
spec/basedir-...](https://specifications.freedesktop.org/basedir-spec/basedir-
spec-latest.html) and
[https://wiki.archlinux.org/index.php/XDG_Base_Directory_supp...](https://wiki.archlinux.org/index.php/XDG_Base_Directory_support)

~~~
little_ori
And the best is if programs don't need any config files.

~~~
daveguy
How else would you save state between program runs? Config files don't
preclude the application from having the ability to modify config from within
the application. Not having config files (or some equivalent) does preclude
saving state. Do you think it would be better to save state to a database or
binary state file? I do not think it would be better. I prefer YAML config for
most everything.

------
justinmk
"dotfiles managers" are over-engineered waste of time. You only need git.
Create ~/.gitignore with a single line:

    
    
        *
    

git tracks modifications to your dotfiles. And on the rare occasion that you
need to add a new file, just force-add it:

    
    
        git add -f ~/.foorc
    

If you need a script to "install" your dotfiles, you're doing it wrong.

~~~
sciencerobot
I tried this but git uses ~/.git for any subdirectory of $HOME. For example,
if you type `git add .` while in ~/code/some-project, you will add it to your
dotfiles repository. It's easy to undo but still kind of annoying.

~~~
justinmk
> For example, if you type `git add .` while in ~/code/some-project, you will
> add it to your dotfiles repository.

If your project has its own .git directory, no, it won't add to ~/.git.

~~~
sciencerobot
You're right. I forgot to mention that this only happens if you haven't
initiated a new git repository in the directory you're working in.

------
ralish
I've found Stow to be outstanding. When I initially started actually
maintaining my _dotfiles_ properly I looked at what others were doing based on
public repositories and most at the time were either not using any sort of
management tool (manual symlinking as needed) or using something written in a
interpreted language that couldn't be assumed to be on a diverse range of
Unix-like systems in default installations (e.g. Ruby, Python, Node.js,
etc...).

The problem was I wanted something I could easily install on effectively any
system, including live servers, without needing to install dependencies or
otherwise change the underlying global system state. Stow manages to solve
this beautifully as pretty much all Unix-like systems do have a Perl
interpreter and Stow has no unusual dependencies beyond the core runtime.
That, and it can be included in your _dotfiles_ collection itself, so you can
literally " _stow stow_ " to " _bootstrap_ " itself and then carry along!

If anyone's interested you can find my _dotfiles_ below which may be nice as
reference material if you're wanting to "stow-ify" your _dotfiles_. I've also
written some Bash scripts to automatically stow the available components on a
given system ( _dot-manage_ ) and easily fetch updates from an upstream
repository, re-run component detection and update Vim bundles via Vundle (
_dot-update_ ). There's also a metadata-esque system which augments detection
of which components are available for where simply checking if a binary named
after the relevant folder exists on the system is insufficient (e.g. for
libraries like _readline_ ).

[https://github.com/ralish/dotfiles](https://github.com/ralish/dotfiles)

~~~
digi_owl
You may want go take a look at Gobolinux. Its a distro that applies a similar
system to package management.

------
herebolt
I like to use rcm[1] for this.

Works very well for keeping my configuration synced between multiple machines
(via git).

[1] [https://github.com/thoughtbot/rcm](https://github.com/thoughtbot/rcm)

------
peterhajas
I've been managing my dotfiles with `stow` for the past ~2 years. It's super
easy, and keeps things clean. `stow` will also guard against non-symlinks
getting stomped on.

My `update.sh` script does un-and-re-`stow`ing:

[https://github.com/peterhajas/dotfiles](https://github.com/peterhajas/dotfiles)

------
jiiam
Oh god, yes! Finally! I'm sick of hundreds of dotfiles forgotten in remote
places of my filesystem, organized via a github repo and deployed with a
handcrafted (by a friend) Rakefile.

The only change I'd make is to deploy by copying (and not by symlinking).

~~~
herebolt
> The only change I'd make is to deploy by copying (and not by symlinking).

But then you lose any changes you make to those files...

~~~
nkuttler
I consider that a feature. When a change has proven to be good enough I copy
it into my repository. I prefer to rsync the files though.

------
bluejekyll
I've seen many people accidentally upload secret keys to external repos
because of things like this.

I didn't see it in what I read (honestly I just breezed through it), does this
prevent secret keys from being uploaded accidentally?

------
ubercow
I'm quite fond of thoughtbot's rcm.

[https://github.com/thoughtbot/rcm](https://github.com/thoughtbot/rcm)

------
Sir_Cmpwn
The solution I eventually came to appreciate is to simply make your home
directory a git repository.

~~~
Pirate-of-SV
Do you remove all files from the directory before cloning or have you found
some other way to get around "fatal: destination path '.' already exists and
is not an empty directory."?

~~~
Sir_Cmpwn

        git init
        git remote add origin ...
        git fetch origin
        git checkout -t origin/master

------
balthamos89
I've been using the "per-application" method (as the article calls it) for
about 4 years now, and it's been working fantastically.

Now if I could only figure out an equally good method for managing my ssh
keys...

A small tip for those working on locked-down systems: if you can't install GNU
Stow, you can use XStow[1] instead. It is a C++ version of Stow (instead of
Perl). It is very easy to build and has very few (if any) dependencies.

[1]: [http://xstow.sourceforge.net](http://xstow.sourceforge.net)

------
corybrown
I guess the automatic linking is nice, but I don't really see a need to switch
vim configurations that often. What am I missing?

~~~
LaFolle
"The problem was always with setting them up on new machine and update it when
I need to."

------
captn3m0
Another happy stow user reporting in. Helps me a lot in managing my dotfiles
across machines, and symlinking has been a huge improvement over rsync. Also,
stow raises an error if it cannot symlink to the file (for eg, if a
file/directory exists there with the same name somewhere in the path), so it
is always non-destructive.

------
sooheon
I use yadm[1]. I don't have extensive experience with others, but I liked the
idea of having my dotfiles in their original place, rather than inside a
dedicated dotfiles folder.

[1]
[https://github.com/TheLocehiliosan/yadm](https://github.com/TheLocehiliosan/yadm)

------
muskalek
I'm using stow to manage my dotfiles since about a year, and it works pretty
well. I tried things like homesick (or homeshick), but they were well
overengineered and too complex for me.

It also works great when you create git submodules for your external
dependencies and manage installing them via stow.

~~~
awinter-py
homesick is such a good name though

------
espin
I use a detached work tree approach to version my dotfiles without having to
symlink or install them, see
[http://enrico.spinielli.net/dotfiles/](http://enrico.spinielli.net/dotfiles/)
for details.

~~~
ashitlerferad
[https://github.com/RichiH/vcsh](https://github.com/RichiH/vcsh)

------
elnappo
I use ansible to manage my dotfiles, configurations, cli and gui tools on OS
X. [https://github.com/elnappo/dotfiles](https://github.com/elnappo/dotfiles)

------
dannysu
I was giving stow a try and was confused why it wasn't symlinking .gitignore.

Turns out .gitignore is on the default ignore list. But you if you add a
.stow-local-ignore file to the directory where your .gitignore is then it
works.

------
pmyjavec
I gave it a go but stow seems to be ignoring files that start with a dot.

Uninstalled and stuck with my 5 line shell script.

------
jaequery
this is a good find, i sorely need this!

------
_mikz
[2003]

~~~
to3m
[2013]... it mentions GitHub...

