-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
156 lines (117 loc) · 4.43 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
146
147
148
149
150
151
152
153
154
155
156
.DEFAULT_GOAL:=help
SHELL:=/bin/zsh
XDG_CACHE_HOME := $(HOME)/.cache
XDG_CONFIG_HOME := $(HOME)/.config
XDG_DATA_HOME := $(HOME)/.local/share
.PHONY: all
cwd := $(shell pwd)
##@ Install
install: macos cfg zsh homebrew homebrew-bundle -fonts bat ## Install all the things
clean: ruby-clean cfg-clean neovim-clean zsh-clean homebrew-clean ## Uninstall all the things
cfg: xdg-setup ## Link configuration files
ln -s $(cwd)/xdg_config $$HOME/.config
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: ## 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_CFG_DIR := "$(XDG_CONFIG_HOME)/nvim"
neovim: neovim-build-from-source ## Install Neovim
NEOVIM_SRC_DIR := "$$HOME/work/neovim/neovim"
NEOVIM_CFG_DIR := "$(XDG_CONFIG_HOME)/nvim"
neovim-clone-or-pull:
@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; \
neovim-build-from-source: ## Install from source
ifeq (, $(shell which cmake))
$(shell brew install cmake)
endif
ifeq (, $(shell which automake))
$(shell brew install automake)
endif
ifeq (, $(shell which ninja))
$(shell brew install ninja)
endif
$(MAKE) -C $(NEOVIM_SRC_DIR) distclean
$(MAKE) -C $(NEOVIM_SRC_DIR)
# $(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_BUILD_TYPE=RelWithDebInfo; \
sudo $(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_INSTALL_PREFIX=/usr/local install
neovim-clean2:
$(shell bin/clean_neovim)
neovim-clean:
-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
-brew unlink neovim
rm -rf $$HOME/.local/share/nvim
##@ Languages
asdf-plugins: ## Install plugins needed for asdf to install the given languages
@if which asdf &> /dev/null ; then \
asdf plugin add nodejs; \
asdf plugin add python; \
asdf plugin add ruby; \
asdf plugin add rust; \
fi
ruby: ruby-cfg ## Install Ruby
ruby-clean: ## Uninstall Ruby
ruby-cfg: ## Link Ruby configuration files
ln -sf $(PWD)/ruby/ruby/.irbrc $$HOME
ruby-cfg-clean: ## Unlink Ruby configuration files
rm $$HOME/.irbrc
##@ zsh
zsh: zsh-cfg ## Install zsh-related items
zsh-clean: zsh-cfg-env-clean ## Uninstall zsh-related items
zsh-cfg: ## Link ~/.zshenv
ln -sf $(cwd)/.zshenv $$HOME/.zshenv
zsh-cfg-clean: ## Unlink ~/.zshenv
rm $$HOME/.zshenv
##@ Misc
XCODE_INSTALLED := $(shell 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
## Font used with toilet banner generator
cp cosmic.flf $$HOMEBREW_CELLAR/toilet/0.3/share/figlet
brew tap homebrew/cask-fonts
brew search '/font-.*-nerd-font/' | awk '{ print $1 }' | xargs brew install --cask
ssh-cfg: ## Install ssh related files
@[ -d $$HOME/.ssh ] || mkdir $$HOME/.ssh
ssh-cfg-clean: ## Install ssh related files
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 XDG dirs (XDG_CONFIG_HOME, etc.)
@[ -d $(XDG_DATA_HOME) ] || mkdir -p $(XDG_DATA_HOME)
@[ -d $(XDG_CACHE_HOME) ] || mkdir -p $(XDG_CACHE_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) $*