Dotfile Management
My public dotfiles can be found here. I use GNUstow
to manage them because it makes it easy to install and manage using symlinks. One of the big benefits is that stow
can automatically figure out how shallow it can symlink without causing issues. In general, I clone my dotfiles to ~/.dotfiles/
and then stow
from there.
Each application can be stored undere ~/.dotfiles/<app name>
and then its config can be installed with ~/.dotfiles # stow <app name>
. This will symlink any files under ~/.dotfiles/<app name>
to the parent directory from which stow
is run, e.g. $HOME
. However, I typically use scripts to manage this even more which I'll discuss in a second.
~/.dotfiles # eza -lA
drwxr-xr-x - ben 28 Oct 12:42 .git
.rw-r--r-- 334 ben 27 Oct 14:04 .gitignore
.rw-r--r-- 412 ben 26 Oct 14:47 .gitmodules
drwxr-xr-x - ben 26 Oct 14:47 alacritty
.rwxr-xr-x 486 ben 26 Oct 14:47 arch
drwxr-xr-x - ben 26 Oct 14:47 awesome
drwxr-xr-x - ben 26 Oct 14:47 bat
drwxr-xr-x - ben 26 Oct 14:47 betterlockscreen
drwxr-xr-x - ben 26 Oct 14:47 bottom
drwxr-xr-x - ben 26 Oct 14:47 bspwm
drwxr-xr-x - ben 26 Oct 14:47 cava
.rwxr-xr-x 239 ben 26 Oct 14:47 clean-env
.rwxr-xr-x 361 ben 26 Oct 14:47 debian
drwxr-xr-x - ben 26 Oct 14:47 dunst
.rwxr-xr-x 359 ben 26 Oct 14:47 fedora
drwxr-xr-x - ben 26 Oct 14:47 fish
.rwxr-xr-x 477 ben 26 Oct 14:47 gentoo
drwxr-xr-x - ben 26 Oct 14:47 hypr
.rwxr-xr-x 226 ben 26 Oct 14:47 install
drwxr-xr-x - ben 26 Oct 14:47 kitty
drwxr-xr-x - ben 26 Oct 14:47 lab
.rw-r--r-- 1.1k ben 26 Oct 14:47 LICENSE
drwxr-xr-x - ben 26 Oct 14:47 mako
drwxr-xr-x - ben 26 Oct 14:47 nvim
.rwxr-xr-x 359 ben 26 Oct 14:47 opensuse
drwxr-xr-x - ben 26 Oct 14:47 picom
drwxr-xr-x - ben 26 Oct 14:47 polybar
drwxr-xr-x - ben 26 Oct 14:47 private
.rw-r--r-- 774 ben 26 Oct 14:47 README.md
drwxr-xr-x - ben 26 Oct 14:47 river
drwxr-xr-x - ben 26 Oct 14:47 rofi
drwxr-xr-x - ben 26 Oct 14:47 scripts
drwxr-xr-x - ben 26 Oct 14:47 starship
drwxr-xr-x - ben 26 Oct 14:47 sway
drwxr-xr-x - ben 26 Oct 14:47 swaylock
drwxr-xr-x - ben 26 Oct 14:47 sxhkd
drwxr-xr-x - ben 26 Oct 14:47 tmux
drwxr-xr-x - ben 26 Oct 14:47 waybar
drwxr-xr-x - ben 26 Oct 14:47 wezterm
drwxr-xr-x - ben 26 Oct 14:47 work
.rwxr-xr-x 375 ben 26 Oct 14:47 work-lab
.rwxr-xr-x 384 ben 26 Oct 14:47 work-mac
.rwxr-xr-x 364 ben 26 Oct 14:47 wsl
drwxr-xr-x - ben 26 Oct 14:47 yambar
drwxr-xr-x - ben 26 Oct 14:47 zsh
It includes the install
script, directories for all my apps that I store the configuration of, and scripts for which apps to install on different platforms.
As an example, my nvim
configuration is stored under ~/.dotfiles/nvim/.config/nvim/<config>
. Any time I run my installation script, stow
will symlink the .config
files to ~/.config/nvim/
.
I use a single, universal install script along with scripts for each distro/machine to manage which configs need to be installed. Here's an example of the distro-specific scripts:
#!/usr/bin/env zsh
# Basic script taken from https://github.com/ThePrimeagen/.dotfiles/blob/master/ubuntu
if [[ -z $STOW_FOLDERS ]]; then
# Folders to install on this host
# WM Stuff
STOW_FOLDERS="dunst,hypr,rofi,scripts,swaylock,waybar"
# Shell Stuff
STOW_FOLDERS+="private,starship,zsh"
# Terminal Stuff
STOW_FOLDERS+="foot,wezterm"
# CLI Stuff
STOW_FOLDERS+="bat,bottom,cava,nvim"
fi
if [[ -z $DOTFILES ]]; then
DOTFILES=$HOME/.dotfiles
fi
STOW_FOLDERS=$STOW_FOLDERS DOTFILES=$DOTFILES $DOTFILES/install
If $STOW_FOLDERS
or $DOTFILES
are not set, it'll set to the default apps for that distro, then it'll run $DOTFILES/install
. If you only want to install some specific files you can easily set $STOW_FOLDERS
on your own before calling the script. The install script looks like this:
#!/usr/bin/env zsh
# Basic script taken from https://github.com/ThePrimeagen/.dotfiles/blob/master/install
pushd $DOTFILES
for folder in $(echo $STOW_FOLDERS | sed "s/,/ /g")
do
stow -D $folder
stow $folder
done
popd
The script is broken down like so:
pushd $DOTFILES
to go to the$DOTFILES
directory and add it to the stack,loop through
$STOW_FOLDERS
,unstow any previous installation in case the files have changed,
stow the new files/directories,
popd
back to the previous directory.Whenever I'm installing my config to a new device (or if I've just added new directories that aren't included in the old symlinks), I run something like
./dotfiles/gentoo
.