-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (99 loc) · 2.97 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
gnu_ln := $(shell &>/dev/null ln --help; echo $$?)
# ---------- Nix ----------
.PHONY: nix
nix: /nix ## Install Nix
/nix:
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
# ---------- Zsh ----------
# generate list of Zsh dot files based on contents of zsh/ directory
# e.g. ~/.zshrc ~/.zprofile ...
zdotfiles := $(foreach f,$(wildcard zsh/*),~/.$(notdir $(f)))
.PHONY: zim
zim: $(zdotfiles)
zim: ~/.zim/modules/asciiship/asciiship.zsh-theme
zim: ## Install the Zim Zsh configuration framework
~/.zim:
@rm -vf -- $(zdotfiles)
curl -fsS https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
rm -rf $@/modules/asciiship
@rm -vf -- $(zdotfiles)
# Zsh dot files must be installed *after* Zim itself, otherwise the installation
# gets aborted prematurely with the message "Zim already installed".
$(zdotfiles): | ~/.zim
ifeq ($(gnu_ln),0)
ln -srTf -- $(subst .,zsh/,$(notdir $@)) $@
else
@rm -vf -- $@
ln -sf -- $(abspath $(subst .,zsh/,$(notdir $@))) $@
endif
~/.zim/modules/asciiship/asciiship.zsh-theme:
zsh -ic 'zimfw install'
# ---------- Git ----------
.PHONY: git
git: ~/.gitconfig ## Configure the Git revision control system
~/.gitconfig:
ifeq ($(gnu_ln),0)
ln -srTf -- gitconfig $@
else
@rm -vf -- $@
ln -sf -- $(abspath gitconfig) $@
endif
# -------- WezTerm --------
.PHONY: wezterm
wezterm: ~/.config/wezterm
wezterm: ~/.wezterm.sh
wezterm: ## Set up the WezTerm terminal emulator and its shell integration
~/.config/wezterm: | ~/.config
ifeq ($(gnu_ln),0)
ln -srTf -- wezterm $@
else
@rm -rvf -- $@
ln -sf -- $(abspath wezterm) $@
endif
~/.wezterm.sh:
curl -fsSo $@ https://raw.githubusercontent.com/wez/wezterm/main/assets/shell-integration/wezterm.sh
# -------- Neovim ---------
.PHONY: nvim clean-nvim
nvim: ~/.config/nvim ## Configure the Neovim text editor
~/.config:
@mkdir $@
~/.config/nvim: | ~/.config
ifeq ($(gnu_ln),0)
ln -srTf -- nvim $@
else
@rm -rvf -- $@
ln -sf -- $(abspath nvim) $@
endif
clean-nvim: ## Delete the Neovim state and caches
@rm -rvf ~/.local/share/nvim ~/.local/state/nvim ~/.cache/nvim ~/.config/nvim
# ---------- Vim ----------
.PHONY: vim
vim: ~/.vimrc ## Configure the Vim text editor
~/.vimrc:
ifeq ($(gnu_ln),0)
ln -srTf -- vimrc $@
else
@rm -vf -- $@
ln -sf -- $(abspath vimrc) $@
endif
# -------- direnv ---------
.PHONY: direnv
direnv: ~/.config/direnv ## Set up direnv
~/.config/direnv: | ~/.config
ifeq ($(gnu_ln),0)
ln -srTf -- direnv $@
else
@rm -rvf -- $@
ln -sf -- $(abspath direnv) $@
endif
# ---------- Misc ----------
.DEFAULT_GOAL := help
.PHONY: help
help:
# source: https://github.com/jessfraz/dotfiles/blob/master/Makefile
# Results are prefixed with the file name when MAKEFILE_LIST has multiple
# values, so we need to additionally handle that case.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":"}; {if (NF < 3) {$$3 = $$2; $$2 = $$1}; print $$2":" $$3}' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'