CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config) FONT_DIR := $(HOME)/.local/share/fonts ZSH_DIR := $(if $(ZSH), $(ZSH), $(HOME)/.oh-my-zsh) SSH_DIR := $(HOME)/.ssh ZSH_CUSTOM_DIR := $(if $(ZSH_CUSTOM), $(ZSH_CUSTOM), $(ZSH_DIR)/custom) HOME_ITEMS := $(wildcard home/*) HOME_TARGETS := $(HOME_ITEMS:home/%=$(HOME)/.%) CONFIG_ITEMS := $(wildcard config/*) CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%) ZSH_ITEMS := $(wildcard ohmyzsh/*.zsh) ZSH_TARGETS := $(ZSH_ITEMS:ohmyzsh/%.zsh=$(ZSH_CUSTOM_DIR)/%.zsh) SSH_ITEMS := $(wildcard ssh/*) SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%) POWERLEVEL_REPO := https://github.com/romkatv/powerlevel10k.git POWERLEVEL_DIR := $(ZSH_CUSTOM_DIR)/themes/powerlevel10k ZSH_SYNTAX_REPO := https://github.com/zsh-users/zsh-syntax-highlighting.git ZSH_SYNTAX_DIR := $(ZSH_CUSTOM_DIR)/plugins/zsh-syntax-highlighting TPM_REPO := https://github.com/tmux-plugins/tpm TPM_DIR := $(HOME)/.tmux/plugins/tpm .PHONY: all clean link unlink install uninstall pacman all: link install clean: unlink uninstall link: $(HOME_TARGETS) $(CONFIG_TARGETS) $(SSH_TARGETS) $(HOME)/.ssh/sockets unlink: for link in $(HOME_TARGETS); do rm "$$link"; done for link in $(CONFIG_TARGETS); do rm "$$link"; done for link in $(SSH_TARGETS); do rm "$$link"; done rmdir $(HOME)/.ssh/sockets install: $(ZSH_DIR) $(POWERLEVEL_DIR) $(ZSH_SYNTAX_DIR) $(ZSH_TARGETS) $(TPM_DIR) python3 -m pip list | grep -E "libtmux.*0\.16\.1" > /dev/null ||\ python3 -m pip install --user libtmux==0.16.1 uninstall: rm -rf $(ZSH_DIR) pacman: sort -h pkglist.txt -o pkglist.txt pacman -T - < pkglist.txt ||\ sudo pacman --needed -S - < pkglist.txt $(HOME_TARGETS): $(HOME)/.%: home/% $(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/% $(ZSH_TARGETS): $(ZSH_CUSTOM_DIR)/%.zsh: ohmyzsh/%.zsh $(SSH_TARGETS): $(SSH_DIR)/%: ssh/% $(HOME_TARGETS) $(CONFIG_TARGETS) $(ZSH_TARGETS) $(SSH_TARGETS): ln -s $(PWD)/$? $@ $(POWERLEVEL_DIR): $(ZSH_DIR) git clone --depth 1 $(POWERLEVEL_REPO) $@ $(ZSH_SYNTAX_DIR): $(ZSH_DIR) git clone --depth 1 $(ZSH_SYNTAX_REPO) $@ $(TPM_DIR): git clone --depth 1 $(TPM_REPO) $@ $(ZSH_DIR): sh -c "$$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" $(CONFIG_DIR) $(SSH_DIR) $(HOME)/.ssh/sockets: mkdir -p $@