My collection of dotfiles. Based on jhbabon/dotfiles
You can install them with make
:
% make
# OR
% make install
And use the clean
rule to uninstall them:
% make clean
If you want to install only one set of dotfiles, for example vim
, run:
% make vim
# To clean
% make clean_vim
If you check the Makefile
you'll see that is quite simple. In fact, there is no rules to install anything. The trick is in this line:
include **/*.mk
What the Makefile
is doing here is searching for any .mk
file in the directories' tree and if it finds one it includes all of the file's rules.
The dotfiles for each app/module are in their own directory (e.g: vim
or zsh
), and inside those directories there is a .mk
file (e.g: vim.mk
or zsh.mk
).
Each of these .mk
files is a new Makefile
with the rules to install that module. In order to make these .mk
files to work with the main Makefile
, they need to be created with a structure. This could be a template for a new module:
MODULE := $(shell command -v module 2>/dev/null)
ifdef MODULE
INSTALLERS += module
CLEANERS += clean_module
MODULE_SRC_DIR := $(DOTFILES)/module
MODULE_DST_DIR := $(CONFIG_DIR)/module
.PHONY: module clean_module
module: banner_install_module
clean_module: banner_clean_module
endif
The most importan part of this file is when we append values to INSTALLERS
and CLEANERS
variables. These variables are the main registries of rules for installation and cleaning. They are used by the main Makefile
to know what rules it should call when running the install
and clean
rules.
The banner_install_%
and banner_clean_%
rules are a simple way to show when a module starts its installation and cleaning rules. Add them as the first prerequisite of your rules to use them.
The idea is to keep each set of dotfiles modular, so if you need to add or remove something it shouldn't affect other files or the main installation process.
To run tests,
- Enter into a shell prompt on the test docker container with:
make test_prompt
(you may need to close vim manually before getting to the shell prompt ¯_(ツ)_/¯) - Run tests with:
make test