Managing dotfiles with GNU stow
i3wm
I recently switched to the i3 window manager, which is a tiling window manager for Linux. Is an example of how it automatically tiles the windows. For a great demonstration of how beautiful you can get i3 to look visit the Reddit community https://reddit.com/r/unixporn. Don’t worry, its safe for work!
Dotfiles
When working with i3, and the other programs which store their configuration in dotfiles, it is a good idea to backup your dotfiles so in the case of an emergency you haven’t lost your configuration (trust me, you get very attached to it!). It is also helpful when you want to reinstall your configuration on another machine, so you don’t have to manually copy over every file.
If you want a configuration similar to mine, my dotfiles can be found on my Github page.
GNU stow
According to the project page GNU stow is
GNU Stow is a symlink farm manager which takes distinct packages of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in the same place. This may sound complicated, but essentially it allows you to collect files in one folder and install them to their required location with a single command.
How to use it
- Install GNU stow
sudo apt install stow
- Create a directory to store all your dotfiles in
mkdir dotfiles cd dotfiles
I would recommend backing this folder up with a version control system, e.g
git
and storing on github. - Create a folder named the program whose configuration files you want to install. For this example I will install vim’s config file
mkdir vim cd vim
The directory now looks like this
dotfiles └── vim
- Move the configuration file into the directory you just made
mv ~/.vimrc .
Directory now looks like this
dotfiles └── vim └── .vimrc
- Install the configuration file back to its correct location. Must be done from root directory, dotfiles in this case.
stow vim
All the files inside of the
vim
folder will now be moved to~/
For more complex configuration files which aren’t just inside ~
you must add the folders inside the directory. For example with the i3 config is stored at ~/.config/i3/config
. When making a new directory inside dotfiles
imagine it is the home directory. So to create a folder to install the i3 config the directory structure would now look like this
dotfiles
└── vim
└── .vimrc
i3
└── .config
└── i3
├── config
So I hope you now know how to use GNU stow to manage your dotfiles!