Skip to content

Dotfile Management with GNU Stow

Published:  at 09:32 PM
Table of Contents

Install Stow

brew install stow

Create a dotfiles folder to store all the dotfiles

mkdir ~/.dotfiles

Create an example file and see if they are symlinked.

cd ~/.dotfiles
mkdir rondomfir
cd rondomfir
touch random.txt
cd ..
stow rondomfir

Check if they are symlinked.

cd ~
ls -lah random.txt

They are symlinked!

Note: You get an error if you try to stow a file that is the same name as an existing file in the home directory

Example:

cd ~
touch random.txt
cd ~/.dotfiles
touch random.txt
stow .
# Doesn't work

Manage with Git

Now you can manage them with git without anything special.

After stowing some settings, it looks like:

tree -a -I ".git|.DS_Store"

Special Cases: VS Code on macOS

VS Code on macOS uses a non-standard path (~/Library/Application Support/Code/User/), which Stow cannot handle. Use manual symlinks instead:

# Move settings to dotfiles
mkdir -p ~/.dotfiles/vscode
mv ~/Library/Application\ Support/Code/User/settings.json ~/.dotfiles/vscode/

# Create symlink
ln -s ~/.dotfiles/vscode/settings.json ~/Library/Application\ Support/Code/User/settings.json

Resources