-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (36 loc) · 1.03 KB
/
Copy pathMakefile
File metadata and controls
42 lines (36 loc) · 1.03 KB
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
DOTFILE_DIR := $(HOME)/.files
EXCLUDES := . .. .git
DOTFILES := $(filter-out $(EXCLUDES), $(shell ls -A -1 $(DOTFILE_DIR)))
default: setup update clean link set_permissions
clean:
for file in $(DOTFILES); do \
/bin/rm -f -r $(HOME)/$${file}; \
done
for link in $(HOME)/.[!.]* $(HOME)/*; do \
if [ -L "$${link}" ] && [ ! -e "$${link}" ]; then \
case "$$(readlink "$${link}")" in \
$(DOTFILE_DIR)/*) /bin/rm -f "$${link}";; \
esac; \
fi; \
done
link:
for file in $(DOTFILES); do \
/bin/ln -n -s $(DOTFILE_DIR)/$${file} $(HOME)/$${file}; \
done
set_permissions:
chmod 700 $(HOME);
chmod u=rwX,g=rX,o= $(DOTFILE_DIR);
for file in $(DOTFILES); do \
case "$${file}" in \
.claude|.gnupg|.ssh) ;; \
*) chmod -R u=rwX,g=rX,o= $(DOTFILE_DIR)/$${file};; \
esac; \
done
chmod -R u=rwX,go= $(DOTFILE_DIR)/.gnupg;
chmod -R u=rwX,go= $(DOTFILE_DIR)/.ssh;
setup:
if [ ! -d $(DOTFILE_DIR) ]; then \
git clone https://github.com/yon/dotfiles.git $(DOTFILE_DIR); \
fi
update: setup
cd $(DOTFILE_DIR) && git pull && cd $(HOME);