-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (110 loc) · 2.98 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
OS_NAME := $(shell uname -s | tr A-Z a-z)
excluded_dotfiles := Makefile
ifeq ($(OS_NAME), darwin)
excluded_dotfiles += fvwm
endif
dotfiles := $(filter-out $(excluded_dotfiles), $(wildcard *))
formulae := \
bat \
cheat \
dash \
erlang \
fd \
fish \
fzf \
gh \
git \
go \
htop \
luajit \
neovim \
nnn \
ripgrep \
ruby-install \
rust \
sqlite \
starship \
tldr \
tmux \
universal-ctags
default: | update clean
ifneq (,$(filter $(OS_NAME), freebsd openbsd))
install: | link fisher ruby vim_plug
else
install: | link fisher ruby vim_plug neovim
endif
update: | install
@echo '==> Updating world...'
ifeq ($(OS_NAME), darwin)
@sudo port selfupdate
endif
@fish -c 'fisher update'
@vim +PlugUpgrade +PlugInstall +PlugUpdate +qall
clean: | install
@echo '==> Cleaning world...'
ifeq ($(OS_NAME), darwin)
ifneq ($(shell port installed inactive),)
@sudo port uninstall inactive
endif
endif
@vim +PlugClean +qall
@rm -f config/nvim/autoload/plug.vim.old
### Linking
prefixed_symlinks = $(addprefix $(HOME)/.,$(dotfiles))
kitty_current_theme = $(HOME)/.config/kitty/current-theme.conf
kitty_os_conf = $(HOME)/.config/kitty/os.conf
link: | $(prefixed_symlinks) $(kitty_current_theme) $(kitty_os_conf)
$(prefixed_symlinks):
@echo '==> Link dotfiles to home directory...'
@$(foreach val, $(dotfiles), ln -sfn $(abspath $(val)) $(HOME)/.$(val);)
$(kitty_current_theme):
@mkdir -p $(HOME)/.config
@cp $(HOME)/.dotfiles/config/kitty/themes/dark.conf $(HOME)/.config/kitty/current-theme.conf
$(kitty_os_conf):
ifeq ($(OS_NAME), darwin)
@ln -sfn $(HOME)/.config/kitty/darwin.conf $(HOME)/.config/kitty/os.conf
else
@ln -sfn $(HOME)/.config/kitty/non-darwin.conf $(HOME)/.config/kitty/os.conf
endif
### Unlinking
unlink:
@echo '==> Remove linked dotfiles in home directory...'
@-$(foreach val, $(dotfiles), rm -rf $(HOME)/.$(val);)
### Ruby
ruby_version := $(shell cat $(PWD)/ruby-version)
ruby_dir = $(HOME)/.rubies
ruby = $(ruby_dir)/ruby-$(ruby_version)
gem = $(ruby)/bin/gem
ruby: | $(ruby) $(bundler)
$(ruby): | $(HOME)/.ruby-version
ruby-install ruby-$(ruby_version) -i $(ruby_dir)/ruby-$(ruby_version)
### Bundler
bundler = $(ruby)/bin/bundle
$(bundler): | $(ruby)
$(gem) install bundler
### plug.vim
vim_plug = $(HOME)/.config/nvim/autoload/plug.vim
vim_plug: | $(vim_plug)
$(vim_plug):
curl -fLo $(vim_plug) --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
mkdir -p $(HOME)/.nvim/tmp
### Neovim
ifeq ($(OS_NAME), darwin)
bin_path := /opt/local/bin
else
bin_path := /usr/local/bin
endif
vim = $(bin_path)/vim
vi = $(bin_path)/vi
neovim: | $(vim) $(vi)
$(vim):
sudo ln -sfn $(bin_path)/nvim $(bin_path)/vim
$(vi):
sudo ln -sfn $(bin_path)/nvim $(bin_path)/vi
### Fish plugin manager
fisher = $(HOME)/.config/fish/functions/fisher.fish
fisher: $(fisher)
$(fisher):
@echo '==> Installing fisher plugin manager...'
@fish -c 'curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher'