Managing dotfiles with Make Make is an old tool, an assembly language of sorts for build systems. Many have tried to replace it. Many have tried to reinvent it. Most people prefer to avoid it if at all possible. So why use it to manage dotfiles of all things? There's at least one good reason to do this: make is ubiquitous. Pretty much every machine that has ever compiled software will have a copy of this thing. Using make as a dotfile management tool eliminates the need to install yet another infrequently used program. Another reason to use it is this turned out to be a surprisingly easy task. File system structure Make works best when everything is as simple as possible. It doesn't provide much functionality: the few path manipulation functions it includes are of the string matching and substitution variety. The easiest way to achieve that simplicity is to mirror the structure of the home directory. Like this: ~/.files ~ .bash_profile .bashrc .vimrc ... GNUmakefile The ~ directory represents the current user's home directory. Configuration files in $HOME will be symbolic links to their corresponding files in the ~ directory of the repository. Make's job is to automatically create those symbolic links. cd ~/.files/ make Simplicity is good. Writing the makefile All link targets are rooted in the repository's ~ directory, so the first thing that must be done is find the repository itself. Make always knows the location of the makefile. Since it is located in the root of the .files repository, it's possible to find the repository itself through it. makefile := $(abspath $(lastword $(MAKEFILE_LIST))) dotfiles := $(abspath $(dir $(makefile))) A reference to the home directory is already available in make via the $HOME environment variable and ~ also works according to the documentation. An equally easy way to refer to the dotfiles repository's ~ directory would be nice. ~ := $(abspath $(dotfiles)/~) Now it is possible to write ~ and $(~) for the user's home directory and...
First seen: 2025-09-30 00:35
Last seen: 2025-09-30 10:36