-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
145 lines (110 loc) · 4.66 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
.DEFAULT_GOAL:=help
SHELL:=/bin/zsh
XDG_CACHE_HOME := $(HOME)/.cache
XDG_CONFIG_HOME := $(HOME)/.config
XDG_DATA_HOME := $(HOME)/.local/share
XDG_STATE_HOME := $(HOME)/.local/state
ZDOTDIR := $(XDG_CONFIG_HOME)/zsh
.PHONY: all
cwd := $(shell pwd)
##@ Install
install: macos cfg zsh homebrew-bundle neovim -fonts bat ## Install all the things
clean: cfg-clean neovim-clean zsh-clean homebrew-clean ## Uninstall all the things
cfg: xdg-setup ## Link configuration files
@[ -e $(XDG_CONFIG_HOME) ] || ln -s $(cwd)/xdg_config $$HOME/.config
@[ -e $$HOME/bin ] || ln -sf $(cwd)/bin $$HOME/bin
cfg-clean: ## Clean (rm) config $XDG_CONFIG_HOME
rm $(XDG_CONFIG_HOME)
rm $$HOME/bin
##@ Homebrew
homebrew: ## Install homebrew
sudo curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | /bin/bash
homebrew-bundle: homebrew ## Install default homebrew formulae
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(/opt/homebrew/bin/brew bundle)"
homebrew-clean: ## Uninstall homebrew
sudo curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh | /bin/bash
rm -r /usr/local/var/homebrew
##@ Neovim
NEOVIM_SRC_DIR := "$$HOME/work/neovim/neovim"
NEOVIM_CFG_DIR := "$(XDG_CONFIG_HOME)/nvim"
neovim: neovim-clone-or-pull /usr/local/bin/nvim neovim-install-plugins ## Install Neovim
neovim-clone-or-pull: ## Clone neovim, or pull the latest
@mkdir -p $$(dirname $(NEOVIM_SRC_DIR))
@if [ -d $(NEOVIM_SRC_DIR) ]; then \
git -C $(NEOVIM_SRC_DIR) pull; \
else \
git clone https://github.com/neovim/neovim.git $(NEOVIM_SRC_DIR); \
fi; \
/usr/local/bin/nvim: ## Install neovim from source
@for pkg in cmake automake ninja; do \
if ! which $$pkg >/dev/null; then \
brew install $$pkg; \
fi; \
done; \
$(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_BUILD_TYPE=RelWithDebInfo; \
sudo $(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_INSTALL_PREFIX=/usr/local install
neovim-plugins: /usr/local/bin/nvim ## Install Neovim plugins
@nvim --headless +Lazy! sync +qa
neovim-clean: ## Uninstall neovim
-sudo rm /usr/local/bin/nvim
-sudo rm /usr/local/bin/vi
-sudo rm -r /usr/local/lib/nvim
-sudo rm -r /usr/local/share/nvim
##@ Languages
mise: homebrew-bundle ## Install all languages configured for mise to handle
mise install
##@ zsh
zsh: zsh-cfg ohmyzsh ## Install zsh-related items
zsh-clean: zsh-cfg-env-clean ## Uninstall zsh-related items
zsh-cfg: ## Link ~/.zshenv
ln -sf $(cwd)/.zshenv $$HOME/.zshenv
ohmyzsh: ## Install Oh My Zsh
ZSH=$$XDG_STATE_HOME/ohmyzsh sh -c "$$(http -b GET https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended --keep-zshrc
ohmyzsh-clean: ## Uninstall Oh My Zsh
@if [ -d "$(XDG_STATE_HOME)/ohmyzsh" ]; then \
rm -rf $(XDG_STATE_HOME)/ohmyzsh; \
else \
echo "Oh My Zsh not found in $(XDG_STATE_HOME)"; \
fi
zsh-cfg-clean: ## Unlink ~/.zshenv
rm $$HOME/.zshenv
##@ Misc
XCODE_INSTALLED := $(shell uname -s | grep Darwin >/dev/null && xcode-select -p 1>/dev/null; echo $$?)
macos: ## Set macOS defaults and install XCode command line developer tools
ifeq ($(shell uname -s), Darwin)
ifeq ($(XCODE_INSTALLED), 1)
xcode-select --install
endif
softwareupdate --install --recommended
./macos
killall Dock
endif
bat: ## Get TokyoNight theme for bat
mkdir -p "$$(bat --config-dir)/themes"
# Replace _night in the lines below with _day, _moon, or _storm if needed.
curl -H "Accept: application/xml" -O https://raw.githubusercontent.com/folke/tokyonight.nvim/main/extras/sublime/tokyonight_night.tmTheme --output-dir "$$(bat --config-dir)/themes"
bat cache --build
fonts: ## Install fonts
brew install font-space-mono-nerd-font
brew install font-blex-mono-nerd-font
brew install font-source-code-pro-for-powerline
## Font used with toilet banner generator
cp cosmic.flf $$HOMEBREW_CELLAR/toilet/0.3/share/figlet
ssh-cfg: ## Install ssh related files
@[ -d $$HOME/.ssh ] || mkdir $$HOME/.ssh
ssh-add-key: -ssh ## Add key to SSH agent
ssh-add -K ~/.ssh/id_ed25519
misc-cfg: ripgrep-cfg lazygit-cfg ## Miscellany
@[ -e $$HISTFILE ] || touch $$HISTFILE
misc-cfg-clean: ripgrep-cfg-clean lazygit-cfg-clean ## Unlink misc configs
xdg-setup: ## Create standard XDG Base Directory Specification directories
@[ -d $(XDG_CONFIG_HOME) ] || mkdir -p $(XDG_CONFIG_HOME)
@[ -d $(XDG_CACHE_HOME) ] || mkdir -p $(XDG_CACHE_HOME)
@[ -d $(XDG_DATA_HOME) ] || mkdir -p $(XDG_DATA_HOME)
@[ -d $(XDG_STATE_HOME) ] || mkdir -p $(XDG_STATE_HOME)
##@ Helpers
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m\t%s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
-%:
-@$(MAKE) $*