TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using GNU Stow to manage your dotfiles (2012)

203 pointsby matthbergover 4 years ago

26 comments

nickjjover 4 years ago
Call me old fashioned but what&#x27;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?<p>If you wanted to you could &amp;&amp; a few symlinks and other commands into 1 copy &#x2F; paste&#x27;able command to get up and running really quickly. It&#x27;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.<p>I&#x27;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: <a href="https:&#x2F;&#x2F;github.com&#x2F;nickjj&#x2F;dotfiles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nickjj&#x2F;dotfiles</a><p>I purposely broke up some of the commands because I know that not everyone will want a 100% replica of my dotfiles. Folks copy &#x2F; paste only the commands they want.
评论 #25565121 未加载
评论 #25565082 未加载
评论 #25564869 未加载
评论 #25566786 未加载
评论 #25566571 未加载
评论 #25564882 未加载
评论 #25565410 未加载
评论 #25567287 未加载
评论 #25564986 未加载
评论 #25567726 未加载
评论 #25565302 未加载
评论 #25568243 未加载
评论 #25567905 未加载
评论 #25565686 未加载
评论 #25566759 未加载
podikiover 4 years ago
STOW is great, it is simple and works well especially combined with git. That&#x27;s what I do [0], and recently combined it with org-mode for literate programming, so each program has just a README.org that then generates all the files via org tangle [1] [2]. For example, here is my file that generates my Xorg configuration [3] over several files, nicely readable on GitHub, in Emacs, or just as plain text.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;podiki&#x2F;dot.me&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;podiki&#x2F;dot.me&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190924102437&#x2F;https:&#x2F;&#x2F;expoundite.net&#x2F;guides&#x2F;dotfile-management" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190924102437&#x2F;https:&#x2F;&#x2F;expoundit...</a><p>[2] <a href="https:&#x2F;&#x2F;orgmode.org&#x2F;manual&#x2F;Working-with-Source-Code.html" rel="nofollow">https:&#x2F;&#x2F;orgmode.org&#x2F;manual&#x2F;Working-with-Source-Code.html</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;podiki&#x2F;dot.me&#x2F;tree&#x2F;master&#x2F;x11" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;podiki&#x2F;dot.me&#x2F;tree&#x2F;master&#x2F;x11</a>
评论 #25567468 未加载
mongolover 4 years ago
I have found that managing dotfiles is not enough. The dotfiles serve no purpose without the software that uses them. My method is to write small scripts, I call them setuplets, that install the software and then symlink the dotfile to its master that I manage in git. In the simplest case, it is just a two line script in a directory, but I have one for each program, and a tool to select which I run when setting up a new linux machine. The more complex ones may install a number of tools and set up environment variables etc. For environment variables, the script drops a script file in a directory, where my bashrc sources it.
评论 #25564823 未加载
评论 #25567648 未加载
评论 #25566207 未加载
评论 #25563946 未加载
评论 #25566600 未加载
评论 #25564879 未加载
meagherover 4 years ago
You don&#x27;t need symlinks, setup scripts, etc. Try this:<p>1. Bare git repo in your home directory ($HOME&#x2F;.files)<p>2. Alias for prefixing git commands (&quot;env GIT_WORK_TREE=$HOME GIT_DIR=$HOME&#x2F;.files&quot;)<p>3. Strict .gitignore file (that ignores all files by default)<p>Simple to add files: `h git add .vimrc`<p>Have this set up for myself. Works great <a href="https:&#x2F;&#x2F;github.com&#x2F;tmm&#x2F;dotfiles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tmm&#x2F;dotfiles</a>
评论 #25565967 未加载
评论 #25568348 未加载
评论 #25568075 未加载
turbinerneiterover 4 years ago
I use this technique, based on a bare git repo <a href="https:&#x2F;&#x2F;www.atlassian.com&#x2F;git&#x2F;tutorials&#x2F;dotfiles" rel="nofollow">https:&#x2F;&#x2F;www.atlassian.com&#x2F;git&#x2F;tutorials&#x2F;dotfiles</a><p>Works quite well ... but I&#x27;m really, really ready for a rebuild of how Linux systems are built. I hope systemd-homed will deliver.<p>Imagine you could ssh into a machine with a flag that forwards your local config. Or even your local bin.
评论 #25563998 未加载
评论 #25563808 未加载
评论 #25563745 未加载
kevlar1818over 4 years ago
I really like this method as opposed to using a bare Git repository. For one, it&#x27;s conceptually simpler in my mind; you don&#x27;t have to understand Git internals to get this working. Secondly, this lets you pick and choose which config files you want to &quot;install&quot; on a machine.<p>I feel obligated to share my Bash script, dotfiles.sh[1], that accomplishes what Stow does, but with a few tweaks that I found particularly useful:<p>dotfiles.sh targets the user&#x27;s home directory by default (i.e. stow -t $HOME).<p>dotfiles.sh never symlinks directories, only files (i.e. stow --no-folding). (This was the straw that broke the camel&#x27;s back and made me roll my own script in the first place.)<p>dotfiles.sh makes backups of local config files and can restore them if you remove your symlinked version.<p>My script is quite old now, and I use it so seldomly I&#x27;m not convinced there aren&#x27;t bugs. YMMV.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;kevin-hanselman&#x2F;dotfiles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kevin-hanselman&#x2F;dotfiles</a>
dividedbyzeroover 4 years ago
I&#x27;m very happy with yadm (<a href="https:&#x2F;&#x2F;yadm.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;yadm.io&#x2F;</a>) – it&#x27;s a thin wrapper around git that adds things like alternate and templated files to use different versions of a file or to switch out part of a config for different systems and built-in support for secrets (not using the latter myself, but it&#x27;s there)
jamespwilliamsover 4 years ago
I’ve been using stow to manage my dotfiles for a long time, works very well.<p>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.
评论 #25564609 未加载
评论 #25568433 未加载
leipertover 4 years ago
I like dotbot [0] and have been using it for a while. How do people manage secrets, I am encrypting with keybase, but really want to move away from it.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;anishathalye&#x2F;dotbot" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;anishathalye&#x2F;dotbot</a>
评论 #25569762 未加载
评论 #25567144 未加载
nsilvestriover 4 years ago
I reinstalled my OS (actually, a jump to an adjacent distro) just last night and was thankful I had set up a dotfiles manager (yadm [0]). yadm is a git wrapper, so a yadm repository is pretty much a git repository.<p>`yay -Qe | cut -f 1 -d &quot; &quot; &gt; .config&#x2F;packages.txt` to back up my packages (without version), push to remote, and then `cd ~ &amp;&amp; yadm clone -f &lt;remote&gt; &amp;&amp; yay -S $(cat .config&#x2F;packages.txt)` to reinstall everything. Piece of cake.<p>The only thing I am missing is tracking system files, like &#x2F;etc&#x2F;pacman.conf, and it looks like there&#x27;s a way to do it with yadm, but it looks a bit clunky and I haven&#x27;t tried.<p>[0] <a href="https:&#x2F;&#x2F;yadm.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;yadm.io&#x2F;</a>
susamover 4 years ago
I follow a similar but handcrafted approach. I have a dotfiles repo with a setup script that automates the creation or deletion of all the symbolic links: <a href="https:&#x2F;&#x2F;github.com&#x2F;susam&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;setup" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;susam&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;setup</a><p>So what I do on any new system is just:<p><pre><code> git clone https:&#x2F;&#x2F;github.com&#x2F;susam&#x2F;dotfiles.git cd dotfiles .&#x2F;setup </code></pre> And if I want to undo all the setup for some reason:<p><pre><code> .&#x2F;setup rm</code></pre>
bxparksover 4 years ago
I love stow. My only complaint is that I cannot seem to remember the name of the command: Is it &quot;grab&quot;, &quot;collect&quot;, &quot;pirate&quot;, &quot;organize&quot;, &quot;install&quot;, &quot;push&quot;, &quot;pull&quot;, ...?<p>So I added a note to myself into my .bashrc about this command, and patted myself on the back. The next time I reinstalled Linux, I couldn&#x27;t remember the name, but I remembered that I wrote a note to myself about it. So opened up my .bashrc, and... I didn&#x27;t feel so smart.
评论 #25564798 未加载
评论 #25564607 未加载
knoebberover 4 years ago
I made <a href="https:&#x2F;&#x2F;dotfilehub.com" rel="nofollow">https:&#x2F;&#x2F;dotfilehub.com</a> as another solution for this.
_-david-_over 4 years ago
I am sure there is a better way but I just do this. It works well enough for my purposes.<p>cd ~<p>git init<p>git remote add origin [URL]<p>git fetch<p>git checkout -f master
评论 #25564558 未加载
评论 #25564555 未加载
评论 #25564570 未加载
tpoacherover 4 years ago
Sounds interesting, but I can&#x27;t help but wonder:<p>&gt; all your dotfiles are now neatly organised<p>isn&#x27;t that what .config is for?<p>&gt; install locally built packages in &#x2F;usr&#x2F;local&#x2F;stow&#x2F;PKGNAME-VERSION [...] so you don’t have to worry about any stray files<p>Isn&#x27;t that what &#x2F;opt is for?<p>&gt; (HN comments live-linking to a repository)<p>So maintain externally and export as needed.<p>... am I missing some really important context here? I downloaded stow to check it out, but the whole &#x27;dotfile&#x2F;installation&#x27; use-case in the article sounds like a nothingburger to me.
评论 #25575091 未加载
pabs3over 4 years ago
Some more ways to manage dotfiles are linked from the vcs-home wiki:<p><a href="https:&#x2F;&#x2F;vcs-home.branchable.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vcs-home.branchable.com&#x2F;</a>
xvilkaover 4 years ago
I did my own super-simple Python script[1] with zero dependencies for symlinking files between multiple computers and platforms.<p>[1] <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;XVilka&#x2F;f124936a336a5a43f54915369719e626" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;XVilka&#x2F;f124936a336a5a43f54915369719e...</a>
lwhsiaoover 4 years ago
I originally went with the bare git repo technique, but found myself not liking how to store multiple computer&#x27;s dotfiles in a single repo.<p>I ended up switching to <a href="https:&#x2F;&#x2F;www.chezmoi.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.chezmoi.io&#x2F;</a>, after learning about it here on HN.
评论 #25568698 未加载
wernstr0mover 4 years ago
There are a ton of utilities for managing dotfiles. Some of them are listed here: <a href="http:&#x2F;&#x2F;dotfiles.github.io&#x2F;utilities&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dotfiles.github.io&#x2F;utilities&#x2F;</a>
QuinnyPigover 4 years ago
It’s over-engineered, but I’ve been using <a href="https:&#x2F;&#x2F;github.com&#x2F;RichiH&#x2F;vcsh" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RichiH&#x2F;vcsh</a> for this for years.
dfboydover 4 years ago
Is this project&#x27;s name a pun on &quot;gnusto&quot;? That&#x27;s the spell in the Infocom game &quot;Enchanter&quot;, which copies a spell into your spellbook.
jsmith99over 4 years ago
Have GNU reinvented the Windows registry?<p>Obviously the Windows registry works terribly in practice, but the idea of a centralised store seems to be coming back into fashion.
johnisgoodover 4 years ago
For this I highly recommend <a href="https:&#x2F;&#x2F;zolk3ri.name&#x2F;cgit&#x2F;zpkg&#x2F;" rel="nofollow">https:&#x2F;&#x2F;zolk3ri.name&#x2F;cgit&#x2F;zpkg&#x2F;</a> which I have been using for years now. It works wonderfully for my use case, and might work for yours, too. It is very simple.<p>Environment variables and their defaults:<p><pre><code> ZPKG_SRC = ~&#x2F;.local&#x2F;pkg ZPKG_DST = ~&#x2F;.local ZPKG_DB = ~&#x2F;.local&#x2F;pkg&#x2F;.db </code></pre> It means that if you install anything from scratch, you have to `<i>make install</i>` (or the like, depending on the build system) it to, say, `<i>~&#x2F;.local&#x2F;pkg&#x2F;foo-1.0</i>` and then run `<i>zpkg link foo:1.0</i>` to install (i.e. link) the &quot;package&quot;.<p>After that you just have to make sure you have (typically in your `<i>~&#x2F;.bash_profile</i>` file):<p>- added `<i>~&#x2F;.local&#x2F;bin</i>` to your `<i>PATH</i>` environment variable, and<p>- added `<i>~&#x2F;.local&#x2F;man</i>` to your `<i>MANPATH</i>` environment variable<p>Seems to do the job. For help, read the source code or type `<i>zpkg --help</i>` which should be of tremendous help.<p>By the way, I have noticed that someone created a package manager with the same name, but its initial commit was in 2019, while this one&#x27;s was in 2017.<p>It is written in OCaml, so you do need to have the OCaml compiler installed. I recommend doing it via `<i>opam</i>`, but your Linux distribution&#x27;s package manager will suffice (simply `<i>ocaml</i>` on Arch Linux, for example). Run `<i>make</i>` to compile it, it will produce a working executable file.<p>Direct link to the source code: <a href="https:&#x2F;&#x2F;zolk3ri.name&#x2F;cgit&#x2F;zpkg&#x2F;tree&#x2F;src&#x2F;zpkg.ml" rel="nofollow">https:&#x2F;&#x2F;zolk3ri.name&#x2F;cgit&#x2F;zpkg&#x2F;tree&#x2F;src&#x2F;zpkg.ml</a><p>If you find any bugs, report it via e-mail which can be found in the `<i>LICENSE</i>` file. I reported a bug before and it was fixed almost immediately. I suppose you can send pull requests or mention missing features, the creator seemed friendly to me.<p>---<p>The above is a modified version of an old comment of mine: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24238587" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24238587</a><p>---<p>To be frank, I forgot how it compares to GNU Stow because it was many years ago, but I did use GNU Stow prior to finding this program. All I remember is that it is way simpler, and it seemed to be perfect for my use case, no more and no less than what I needed. Maybe it works for you, too.
fb03over 4 years ago
guys, STOW + SYNCTHING is the way to go for me.
kemitchellover 4 years ago
Anyone move from thoughtbot&#x27;s rcm to stow? How do they compare?
new_realistover 4 years ago
yadm is better.