-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (106 loc) · 4.19 KB
/
Copy pathMakefile
File metadata and controls
132 lines (106 loc) · 4.19 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
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
SHELL = /bin/bash
DOTFILES_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
OS := $(shell bin/is-supported bin/is-macos macos linux)
HOMEBREW_PREFIX := $(shell bin/is-supported bin/is-macos /opt/homebrew /home/linuxbrew/.linuxbrew)
PATH := $(HOMEBREW_PREFIX)/bin:$(DOTFILES_DIR)/bin:$(PATH)
SHELL := env PATH=$(PATH) /bin/bash
SHELLS := /private/etc/shells
BIN := $(HOMEBREW_PREFIX)/bin
export XDG_CONFIG_HOME := $(HOME)/.config
export STOW_DIR := $(DOTFILES_DIR)
.PHONY: test
all: $(OS)
macos: sudo core-macos macos-packages link packages copilot-global
linux: core-linux link
# post link packages
packages: asdf-packages node-packages
core-macos: brew bash git oh-my-zsh
core-linux:
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -f
stow-macos: brew
is-executable stow || brew install stow
stow-linux: core-linux
is-executable stow || apt-get -y install stow
sudo:
ifndef GITHUB_ACTION
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
endif
macos-packages: brew-packages cask-apps
link: stow-$(OS)
# backup old dotfiles
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE -a ! -h $(HOME)/$$FILE ]; then \
mv -v $(HOME)/$$FILE{,.bak}; fi; done
mkdir -p $(XDG_CONFIG_HOME)
stow -t $(HOME) runcom
stow -t $(XDG_CONFIG_HOME) config
.PHONY: copilot
copilot: stow-$(OS)
@echo "Select instruction files from config/copilot/instructions to activate in .github/instructions";
bin/copilot-select
@echo "Workspace chat modes in .github/chatmodes are already active.";
@echo "Run 'make copilot-global' for optional user-level linking.";
.PHONY: copilot-global
copilot-global: stow-$(OS)
@echo "Linking user-level Copilot instructions, chat modes, and agents (advanced)."
mkdir -p "$(HOME)/Library/Application Support/Code/User/prompts"
find "$(HOME)/Library/Application Support/Code/User/prompts" -type l -exec rm {} \; || true
if [ -d "$(DOTFILES_DIR)/config/copilot/chatmodes" ]; then \
for FILE in $(DOTFILES_DIR)/config/copilot/chatmodes/*.chatmode.md; do \
ln -sf "$$FILE" "$(HOME)/Library/Application Support/Code/User/prompts/$$(basename $$FILE)"; \
done; \
echo "✓ Linked user-level chat modes"; \
fi
if [ -d "$(DOTFILES_DIR)/config/copilot/agents" ]; then \
for FILE in $(DOTFILES_DIR)/config/copilot/agents/*.agent.md; do \
ln -sf "$$FILE" "$(HOME)/Library/Application Support/Code/User/prompts/$$(basename $$FILE)"; \
done; \
echo "✓ Linked custom agent files"; \
fi
@echo "✓ Global Copilot linking complete."
unlink: stow-$(OS)
stow --delete -t $(HOME) runcom
stow --delete -t $(XDG_CONFIG_HOME) config
# restore old dotfiles
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE.bak ]; then \
mv -v $(HOME)/$$FILE.bak $(HOME)/$${FILE%%.bak}; fi; done
brew:
is-executable brew || curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash
asdf:
brew list asdf || brew install asdf
oh-my-zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
bash: brew
ifdef GITHUB_ACTION
if ! grep -q bash $(SHELLS); then \
brew install bash bash-completion@2 pcre && \
sudo append $(shell which bash) $(SHELLS) && \
sudo chsh -s $(shell which bash); \
fi
else
if ! grep -q bash $(SHELLS); then \
brew install bash bash-completion@2 pcre && \
sudo append $(shell which bash) $(SHELLS) && \
chsh -s $(shell which bash); \
fi
endif
git: brew
brew list git || brew install git
brew list git || brew install git-extras
brew-packages: brew
brew bundle --file=$(DOTFILES_DIR)/install/Brewfile
cask-apps: brew
brew bundle --file=$(DOTFILES_DIR)/install/Caskfile || true
for EXT in $$(cat install/VSCodefile); do code-insiders --install-extension $$EXT; done
asdf-packages: asdf
cd $(DOTFILES_DIR)/runcom && \
cut -d' ' -f1 .tool-versions | xargs -I{} sh -c 'asdf plugin list | grep -qx "{}" || asdf plugin add "{}"' && \
asdf install
node-packages: asdf-packages
# Reshim nodejs to ensure global packages are linked correctly after installation
ASDF_BIN="$$(brew --prefix asdf)/bin/asdf" && \
"$$ASDF_BIN" exec npm install -g $(shell cat install/npmfile) && "$$ASDF_BIN" exec npm install -g $(shell cat runcom/.default-npm-packages)
test:
bats test