GNU Make Dotfile Management

Everyone knows about pushing your dotfiles to github/bitbucket or whatever version control provider you like best but not many people implement a way to copy or link the dotfiles.

Lots of people use bloated gems to manage the linking or even write their own. For me though these are just over-engineered for my needs and completely unnecessary. My solution is to use a tool that will be already on everyone’s machine (most likely) GNU/Make - nice and straight forward!

Below is a copy of my Makefile which I used to keep my desktop and my laptop in sync. You can also find it on my git account.


DOTFILES = $(shell pwd)
all : linkfiles linkfolders linkmisc
linkfiles:: bashrc vimrc xinitrc Xresources
  for file in $^; do ln -fs $(DOTFILES)/$$file ${HOME}/.$$file; done
linkfolders:: vim ncmpcpp
  for folder in $^; do ln -fns $(DOTFILES)/$$folder ${HOME}/.$$folder; done
linkmisc:: bin dwm
  for folder in $^; do ln -fns $(DOTFILES)/$$folder ${HOME}/$$folder; done