-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·154 lines (133 loc) · 4.5 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·154 lines (133 loc) · 4.5 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env bash
# setup.sh - Main interactive setup script for dev-setup
# This script provides an interactive menu to install and configure
# your development environment
# Get script directory and source common utilities
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/common/utils.sh"
print_header "Development Environment Setup"
print_info "This script will help you set up your macOS development environment"
print_info "You can choose which components to install"
echo ""
# Function to prompt for yes/no
ask_yes_no() {
local prompt="$1"
local default="${2:-n}"
if [[ "$default" == "y" ]]; then
prompt="$prompt [Y/n]: "
else
prompt="$prompt [y/N]: "
fi
read -p "$prompt" -n 1 -r
echo ""
if [[ "$default" == "y" ]]; then
[[ $REPLY =~ ^[Nn]$ ]] && return 1 || return 0
else
[[ $REPLY =~ ^[Yy]$ ]] && return 0 || return 1
fi
}
# Function to run a component script
run_component() {
local script_path="$1"
local component_name="$2"
if [[ -f "$script_path" ]]; then
print_header "Running $component_name"
bash "$script_path"
if [[ $? -eq 0 ]]; then
print_success "$component_name completed successfully"
else
print_error "$component_name failed"
if ask_yes_no "Continue with remaining components?"; then
return 0
else
exit 1
fi
fi
else
print_error "Script not found: $script_path"
return 1
fi
}
# Welcome message
echo "This setup will guide you through installing:"
echo " • Common development tools (via Homebrew)"
echo " • Python development tools (pipx, poetry, pdm, uv, etc.)"
echo " • Web development tools (Node.js, npm packages)"
echo " • Database systems (PostgreSQL, MySQL, Redis, etc.)"
echo " • Shell configuration (bash, zsh, or fish)"
echo " • macOS system defaults for developers"
echo ""
print_info "You'll be prompted for each component"
echo ""
# Ask for sudo password upfront
print_info "Some components require administrator privileges"
sudo -v
# Keep-alive: update existing sudo time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Component 1: Common Development Tools
echo ""
if ask_yes_no "Install common development tools via Homebrew?" "y"; then
run_component "$SCRIPT_DIR/common/brew-common.sh" "Common Development Tools"
fi
# Component 2: Python Development Tools
echo ""
if ask_yes_no "Install Python development tools (pipx, poetry, pdm, uv, etc.)?" "y"; then
run_component "$SCRIPT_DIR/common/python-common.sh" "Python Development Tools"
fi
# Component 3: Web Development Tools
echo ""
if ask_yes_no "Install web development tools (Node.js, npm packages, etc.)?"; then
run_component "$SCRIPT_DIR/common/web-common.sh" "Web Development Tools"
fi
# Component 4: Database Systems
echo ""
if ask_yes_no "Install database systems (PostgreSQL, MySQL, Redis, etc.)?"; then
run_component "$SCRIPT_DIR/common/datastores-common.sh" "Database Systems"
fi
# Component 5: Shell Configuration
echo ""
print_info "Shell Configuration"
echo "Which shell would you like to set up?"
echo " 1) Bash"
echo " 2) Zsh (recommended for macOS)"
echo " 3) Fish"
echo " 4) Skip shell setup"
echo ""
read -p "Enter your choice [1-4]: " -n 1 -r shell_choice
echo ""
case "$shell_choice" in
1)
run_component "$SCRIPT_DIR/shells/bash-setup.sh" "Bash Shell"
;;
2)
run_component "$SCRIPT_DIR/shells/zsh-setup.sh" "Zsh Shell"
;;
3)
run_component "$SCRIPT_DIR/shells/fish-setup.sh" "Fish Shell"
;;
4)
print_info "Skipping shell setup"
;;
*)
print_error "Invalid choice. Skipping shell setup."
;;
esac
# Component 6: macOS Defaults
echo ""
if ask_yes_no "Apply macOS system defaults for developers?"; then
run_component "$SCRIPT_DIR/macos-defaults.sh" "macOS System Defaults"
fi
# Completion
print_header "Setup Complete!"
echo ""
print_success "Your development environment setup is complete!"
echo ""
print_info "Next steps:"
echo " • Restart your terminal to apply all changes"
echo " • Review your shell configuration files"
echo " • Check installed applications in /Applications"
echo " • Run individual components again with ./run.sh if needed"
echo ""
print_info "To update your environment later, simply run ./setup.sh again"
echo ""
print_success "Happy coding!"