-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (64 loc) · 2.05 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
TIMESTAMP := $(shell date +%s)
# default target
.PHONY: help
help:
@echo "usage: make <target>"
@echo
@echo " where <target> is one of the following"
@echo
@echo " vimrc to back up ~/.vimrc to ~/.bak/.vimrc.<timestamp> (creates ~/.bak/ if needed),"
@echo " to copy this repo's .vimrc to ~ and"
@echo " to invoke vim plugin installation"
@echo
@echo " zshrc to back up ~/.zshrc to ~/.bak/.zshrc.<timestamp> (creates ~/.bak/ if needed) and"
@echo " to copy this repo's .zshrc along with .misc to ~"
@echo
@echo " all to run all targets"
@echo
@echo " help to show this text"
# checks existence of required tool stack, fails if not available
.PHONY: needs_curl
needs_curl:
curl --version > /dev/null
.PHONY: needs_vim
needs_vim: needs_grep
vim --version | grep python3 > /dev/null
.PHONY: needs_grep
needs_grep:
grep --version > /dev/null
.PHONY: needs_gopls
needs_gopls:
gopls version > /dev/null
.PHONY: needs_zsh
needs_zsh:
zsh --version > /dev/null
# tasks
.PHONY: zshrc
zshrc: needs_zsh
@echo "############ BACKUP .zshrc ############"
mkdir -p ~/.bak
ifeq ($(shell test -s ~/.zshrc && echo -n yes),yes)
cp ~/.zshrc ~/.bak/.zshrc.${TIMESTAMP}
endif
@echo
@echo "############### INSTALL ###############"
cp .zshrc ~
cp .misc ~
@echo "==============> Done with zsh config, to activate: source ~/.zshrc"
.PHONY: vimrc
vimrc: needs_curl needs_vim needs_gopls
@echo "############### BACKUP ###############"
mkdir -p ~/.bak
ifeq ($(shell test -s ~/.vimrc && echo -n yes),yes)
cp ~/.vimrc ~/.bak/.vimrc.${TIMESTAMP}
endif
@echo
@echo "############### INSTALL ###############"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cp .vimrc ~
@echo "==============> When the following pauses, press a key to continue and wait for the plugin installation to finish!"
vim -c ":PlugInstall" -c ":qall!" 2>/dev/null
@echo "==============> Done with Vim setup, happy Vim-ing."
.PHONY: all
all: zshrc vimrc
@echo "==============> Installed all dotfiles"