A concise tutorial on how to do what you know you should do…
Table of Contents
This tutorial is intended to be a very short and concise guide on how to manage your dotfiles with GNU Stow. If you’d like to learn more, please check out the Resources section towards the end.
I won’t elaborate on why it’s a good idea to keep your dotfiles and configs in a backed up version control system. Just trust me on this one :)
The biggest obstacle to managing your dotfiles is the fact that they are located in your home directory. That’s a pain because the contents of this directory are mostly irrelevant. If you’d try to exclude them manually, it would become daunting very quickly.
Many solutions have been devised to solve this problem. Most of them simply automate the process of replacing the dotfiles with symlinks. That way, you’ll be able to move these files to a dedicated directory that will be version controlled and backed-up.
Installing GNU Stow
If you’re running a mature Linux distro, installing Stow should be a breeze.
On Ubuntu, you’d do this -
sudo apt-get install stow
For other platforms, consult the Download section on the official site.
Setting up a Dotfiles Git Repository
For this guide, I’ll use my personal dotfiles as an example.
At the time of this writing, my home directory (/home/itayg/) had three dotfiles that were essential to my workflow.
Those were: my
.spacemacs config, my
.zshrc and my i3 config file.
The following is the representative directory tree structure -
/home/itayg/ ├── .i3 │ └── config ├── .spacemacs └── .zshrc
Now that it’s clear what we’re dealing with, let’s start off by creating our
mkdir dotfiles cd dotfiles git init
Now we can move on to organize
~/dotfiles for working with Stow.
But to do that, you should understand the basics of how Stow works.
stow command takes a directory as an argument and creates symlinks to its content.
These symlinks are placed in the parent directory relative to your current working directory.
That’s the simplest use case and the one we’ll utilize.
With that said, let’s setup
(Before continuing, PLEASE make sure to backup your dotfiles!)
mkdir spacemacs mv ~/.spacemacs spacemacs mkdir zsh mv ~/.zshrc zsh mkdir i3 mv ~/.i3 i3
Don’t forget to commit your changes -
git add . git commit -m "Add my awesome dotfiles"
That’s it. We’re almost done! Wasn’t so bad, right?
All we have to now is invoke
Make sure you’re in the
cd ~/dotfiles stow spacemacs stow zsh stow i3
If I want to go the extra mile, you could even extract the
to a bash script. Say,
You can take a look at my setup.sh.
Copyright © Itay Garin 2016.
Itay is a developer and a researcher who's passionate about solving low-level challenges. He loves to tinker with electronics, to optimize his Emacs config, and to learn new technologies.