-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (90 loc) · 5.05 KB
/
Makefile
File metadata and controls
122 lines (90 loc) · 5.05 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
# =============================================================================
# Dotfiles — Makefile
# =============================================================================
DOTFILES_DIR := $(shell pwd)
CONFIG_DIR := $(DOTFILES_DIR)/configs
SHELL := /bin/bash
.PHONY: help install install-full install-overlay install-minimal uninstall \
lint test backup restore update stow-% unstow-% \
snapshot snapshot-list snapshot-diff rollback snapshot-cleanup
# ─── Default ──────────────────────────────────────────────────────────────
help: ## Show this help
@echo ""
@echo " Dotfiles — available commands:"
@echo ""
@grep -E '^[a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ""
# ─── Installation ────────────────────────────────────────────────────────
install: ## Auto-detect platform and install (interactive)
@bash install.sh
install-full: ## Full installation (all tools + configs)
@bash install.sh full
install-overlay: ## Overlay mode (for Omarchy / existing setups)
@bash install.sh overlay
install-minimal: ## Minimal mode (only missing tools)
@bash install.sh minimal
install-dry: ## Dry-run — preview what would be installed
@bash install.sh --dry-run full
install-yes: ## Non-interactive full install (accept all defaults)
@bash install.sh --yes full
# ─── Uninstall ────────────────────────────────────────────────────────────
uninstall: ## Remove all stowed dotfiles symlinks
@bash install.sh uninstall
# ─── Individual stow operations ──────────────────────────────────────────
stow-%: ## Stow a single config (e.g., make stow-neovim)
@cd $(CONFIG_DIR) && stow -t ~ --adopt $* && git checkout -- $*
@echo "✓ Stowed: $*"
unstow-%: ## Unstow a single config (e.g., make unstow-neovim)
@cd $(CONFIG_DIR) && stow -t ~ -D $*
@echo "✓ Unstowed: $*"
restow-%: ## Re-stow a single config (unstow + stow)
@cd $(CONFIG_DIR) && stow -t ~ -R --adopt $* && git checkout -- $*
@echo "✓ Re-stowed: $*"
# ─── Maintenance ──────────────────────────────────────────────────────────
lint: ## Run shellcheck on all shell scripts
@echo "Running shellcheck..."
@find . -name '*.sh' -not -path './configs/zsh/.zsh/*' -not -path './configs/tools/.tools/*' \
| xargs shellcheck --severity=warning || true
@echo "✓ Lint complete"
update: ## Pull latest changes and re-stow configs
@git pull --rebase
@bash install.sh --yes full
@echo "✓ Updated"
snapshot: ## Take a snapshot of current configs before changes
@bash -c 'source lib/stow.sh; snapshot_create manual'
snapshot-list: ## List all available snapshots
@bash -c 'source lib/stow.sh; snapshot_list'
snapshot-diff: ## Show changes since last snapshot (usage: make snapshot-diff ID=<id>)
@bash -c 'source lib/stow.sh; \
if [ -n "$(ID)" ]; then snapshot_diff "$(ID)"; \
else \
latest=$$(ls -1d $$HOME/.dotfiles-backup/*/ 2>/dev/null | tail -1 | xargs basename 2>/dev/null); \
if [ -n "$$latest" ]; then snapshot_diff "$$latest"; \
else echo "No snapshots found"; fi; \
fi'
rollback: ## Restore the most recent valid snapshot
@bash -c 'source lib/stow.sh; snapshot_rollback'
restore: ## Restore a specific snapshot (interactive)
@bash -c 'source lib/stow.sh; snapshot_list; echo ""; \
read -rp "Enter snapshot ID to restore: " id; \
snapshot_restore "$$id"'
snapshot-cleanup: ## Remove old snapshots, keep 5 most recent
@bash -c 'source lib/stow.sh; snapshot_cleanup 5'
backup: ## (Legacy) Alias for snapshot-list
@bash -c 'source lib/stow.sh; snapshot_list'
# ─── Release ──────────────────────────────────────────────────────────────
version: ## Show current version (latest tag)
@git describe --tags --abbrev=0 2>/dev/null || echo "no releases yet"
changelog: ## Show changes since last release
@TAG=$$(git describe --tags --abbrev=0 2>/dev/null); \
if [ -n "$$TAG" ]; then \
echo "Changes since $$TAG:"; echo ""; \
git log "$$TAG..HEAD" --oneline --no-merges; \
else \
echo "No releases yet. All commits:"; echo ""; \
git log --oneline --no-merges -20; \
fi
# ─── Info ─────────────────────────────────────────────────────────────────
doctor: ## Check system for required tools and health
@bash $(DOTFILES_DIR)/scripts/doctor.sh $(CONFIG_DIR)