Get the highlights in your inbox every week.
Use Stow for configuration management of multiple machines | Opensource.com
Use Stow for configuration management of multiple machines
Learn how to use Stow to manage configurations across machines in the second article in our series on 20 ways to be more productive with open source in 2020.
Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.
Manage symlinks with Stow
Yesterday, I explained how I keep my files in sync across multiple machines with Syncthing. But that's only one of the tools I use to keep my configurations consistent. The other is a seemingly simple tool called Stow.
Stow manages symlinks. By default, it makes symlinks from the directory it is in to the directory below it. There are also options to set a source and target directory, but I don't usually use them.
As I mentioned in the Syncthing article, I use Syncthing to keep a directory called myconfigs consistent across all of my machines. The myconfigs directory has several subdirectories underneath it. Each subdirectory contains the configuration files for one of the applications I use regularly.
On each machine, I change to the myconfigs directory and run stow -S <directory name> to symlink the files inside the directory to my home directory. For example, under the vim directory, I have my .vimrc and .vim directories. On each machine, I run stow -S vim to create the symlinks ~/.vimrc and ~/.vim. When I make a change to my Vim configuration on one machine, it applies to ALL of my machines.
Sometimes, though, I need something machine-specific, which is why I have directories like msmtp-personal and msmtp-elastic (my employer). Since my msmtp SMTP client needs to know what email server to relay through, and each one has different setups and credentials, I can use Stow to swap between the two by "unstowing" one with the -D flag and then putting the other in place.
Stow lets me switch between several configurations with a simple command line and, in combination with Syncthing, I can be sure that I have the setup I like for the tools I use ready to go, no matter where I am or where I make changes.