-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·140 lines (127 loc) · 3.98 KB
/
bootstrap.sh
File metadata and controls
executable file
·140 lines (127 loc) · 3.98 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
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
# bootstrap.sh
# Main entry point for dotfiles setup
#
# Usage:
# ./bootstrap.sh [--install|--uninstall] [--dry-run] [components...]
#
# Modes:
# --install Install dotfiles and packages (default)
# --uninstall Remove dotfiles and packages
# --dry-run Preview changes without applying them
#
# Components:
# vim, git, tmux, bash, nvm (or 'all' for everything)
set -eu
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source utilities
source "$SCRIPT_DIR/utils/detect.sh"
# ============================================================================
# Main
# ============================================================================
main() {
local MODE="$1"
local DRY_RUN="$2"
shift 2
local COMPONENTS=("$@")
# Detect platform
PLATFORM=$(detect_platform)
echo ""
echo "========================================"
echo " Dotfiles Bootstrap"
echo "========================================"
echo " Platform: $PLATFORM"
echo " Mode: $MODE"
if [ "$DRY_RUN" = "true" ]; then
echo " Dry Run: ENABLED (no changes will be made)"
fi
if [ ${#COMPONENTS[@]} -gt 0 ]; then
echo " Components: ${COMPONENTS[*]}"
else
echo " Components: all"
fi
echo "========================================"
echo ""
# Export DRY_RUN for child scripts
export DRY_RUN
# Delegate to platform-specific setup
case "$PLATFORM" in
macos)
bash "$SCRIPT_DIR/platform/macos/setup.sh" "$MODE" "${COMPONENTS[@]}"
;;
ubuntu)
bash "$SCRIPT_DIR/platform/ubuntu/setup.sh" "$MODE" "${COMPONENTS[@]}"
;;
*)
echo "ERROR: Unsupported platform: $PLATFORM"
echo "Supported platforms: macOS, Ubuntu"
exit 1
;;
esac
}
# ============================================================================
# Command Line Interface
# ============================================================================
MODE="install"
DRY_RUN="false"
COMPONENTS=()
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--install)
MODE="install"
shift
;;
--uninstall)
MODE="uninstall"
shift
;;
--dry-run)
DRY_RUN="true"
shift
;;
-h|--help)
echo "Usage: $0 [--install|--uninstall] [--dry-run] [components...]"
echo ""
echo "Modes:"
echo " --install Install dotfiles and packages (default)"
echo " --uninstall Remove dotfiles and packages"
echo " --dry-run Preview changes without applying them"
echo ""
echo "Components (optional):"
echo " vim Vim editor with vim-plug"
echo " git Git configuration"
echo " tmux Tmux terminal multiplexer"
echo " bash Bash configuration with bash-git-prompt"
echo " nvm Node Version Manager"
echo " pyenv Python version manager"
echo " pipx Python application installer"
echo " uv Python package and project manager"
echo " rust Rust programming language (via rustup)"
echo " all All components (default if none specified)"
echo ""
echo "Examples:"
echo " $0 # Install everything"
echo " $0 --dry-run # Preview installation"
echo " $0 --install vim git # Install only vim and git"
echo " $0 --install bash # Install only bash"
echo " $0 --install pyenv # Install only pyenv"
echo " $0 --dry-run --install vim # Preview vim installation"
echo " $0 --uninstall vim # Uninstall only vim"
echo " $0 --uninstall # Uninstall everything"
exit 0
;;
vim|git|tmux|bash|nvm|pyenv|pipx|uv|rust|all)
COMPONENTS+=("$1")
shift
;;
*)
echo "Unknown option or component: $1"
echo "Usage: $0 [--install|--uninstall] [--dry-run] [components...]"
echo "Run '$0 --help' for more information"
exit 1
;;
esac
done
# Execute
main "$MODE" "$DRY_RUN" "${COMPONENTS[@]}"