-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·265 lines (226 loc) · 6.82 KB
/
install.sh
File metadata and controls
executable file
·265 lines (226 loc) · 6.82 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
# Universal Installation Script for Modern Shell Setup
# Automatically detects OS and runs appropriate setup script
set -e
# Colors for output
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly PURPLE='\033[0;35m'
readonly CYAN='\033[0;36m'
readonly WHITE='\033[1;37m'
readonly NC='\033[0m'
print_header() {
echo -e "${BLUE}═══════════════════════════════════════════════════════════════════${NC}"
echo -e "${WHITE} 🚀 Modern Shell Environment Setup 🚀${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════════${NC}"
echo
}
print_section() {
echo -e "${CYAN}▶ $1${NC}"
}
print_success() {
echo -e "${GREEN}✅ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
print_info() {
echo -e "${PURPLE}ℹ️ $1${NC}"
}
# Detect operating system
detect_os() {
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
SETUP_SCRIPT="setup/macos-setup.sh"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
SETUP_SCRIPT="legacy/bashSetup.sh"
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
OS="windows"
SETUP_SCRIPT="setup/windows-setup.ps1"
else
print_error "Unsupported operating system: $OSTYPE"
exit 1
fi
print_info "Detected OS: $OS"
}
# Check if script exists
check_setup_script() {
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local full_script_path="$script_dir/$SETUP_SCRIPT"
if [[ ! -f "$full_script_path" ]]; then
print_error "Setup script not found: $full_script_path"
exit 1
fi
SCRIPT_PATH="$full_script_path"
print_info "Setup script: $SETUP_SCRIPT"
}
# Show options menu
show_menu() {
echo -e "${YELLOW}What would you like to install?${NC}"
echo
echo "1) Complete setup (recommended)"
echo "2) Fonts only"
echo "3) Shell configuration only"
echo "4) Development tools only"
echo "5) Custom installation"
echo "6) Exit"
echo
}
# Run macOS setup
run_macos_setup() {
print_section "Running macOS Setup"
if [[ ! -x "$SCRIPT_PATH" ]]; then
chmod +x "$SCRIPT_PATH"
fi
"$SCRIPT_PATH"
}
# Run Windows setup
run_windows_setup() {
print_section "Running Windows Setup"
if command -v powershell >/dev/null 2>&1; then
powershell -ExecutionPolicy Bypass -File "$SCRIPT_PATH"
elif command -v pwsh >/dev/null 2>&1; then
pwsh -ExecutionPolicy Bypass -File "$SCRIPT_PATH"
else
print_error "PowerShell not found. Please install PowerShell to continue."
exit 1
fi
}
# Run Linux setup
run_linux_setup() {
print_section "Running Linux Setup"
if [[ ! -x "$SCRIPT_PATH" ]]; then
chmod +x "$SCRIPT_PATH"
fi
"$SCRIPT_PATH"
}
# Install fonts only
install_fonts_only() {
print_section "Installing Fonts Only"
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local font_script="$script_dir/setup/fonts/install-nerd-fonts.sh"
if [[ -f "$font_script" ]]; then
if [[ ! -x "$font_script" ]]; then
chmod +x "$font_script"
fi
"$font_script"
else
print_error "Font installation script not found"
exit 1
fi
}
# Show system information
show_system_info() {
print_section "System Information"
echo "Hostname : $(hostname)"
echo "OS : $OS"
echo "Architecture : $(uname -m)"
echo "Shell : $SHELL"
echo "User : $USER"
if [[ "$OS" == "macos" ]]; then
echo "macOS Version: $(sw_vers -productVersion)"
elif [[ "$OS" == "linux" ]]; then
if [[ -f /etc/os-release ]]; then
source /etc/os-release
echo "Distribution : $NAME $VERSION"
fi
echo "Kernel : $(uname -r)"
fi
echo
}
# Interactive menu
interactive_setup() {
while true; do
show_menu
read -p "Enter your choice (1-6): " choice
case $choice in
1)
print_info "Starting complete setup..."
case $OS in
"macos") run_macos_setup ;;
"linux") run_linux_setup ;;
"windows") run_windows_setup ;;
esac
break
;;
2)
install_fonts_only
break
;;
3)
print_warning "Shell configuration only is not yet implemented"
print_info "Please choose complete setup for now"
;;
4)
print_warning "Development tools only is not yet implemented"
print_info "Please choose complete setup for now"
;;
5)
print_warning "Custom installation is not yet implemented"
print_info "Please choose complete setup for now"
;;
6)
print_info "Installation cancelled"
exit 0
;;
*)
print_error "Invalid choice. Please enter 1-6."
;;
esac
done
}
# Main function
main() {
print_header
show_system_info
detect_os
check_setup_script
# Check if running with --fonts-only flag
if [[ "$1" == "--fonts-only" ]]; then
install_fonts_only
exit 0
fi
# Check if running with --auto flag
if [[ "$1" == "--auto" ]]; then
print_info "Running automatic setup..."
case $OS in
"macos") run_macos_setup ;;
"linux") run_linux_setup ;;
"windows") run_windows_setup ;;
esac
exit 0
fi
# Show help if requested
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Modern Shell Environment Setup"
echo
echo "Usage: $0 [OPTIONS]"
echo
echo "Options:"
echo " --auto Run automatic setup based on detected OS"
echo " --fonts-only Install fonts only"
echo " -h, --help Show this help message"
echo
echo "Without options, runs interactive setup menu."
echo
exit 0
fi
# Run interactive setup
interactive_setup
echo
print_success "🎉 Setup completed! 🎉"
echo
print_info "Next steps:"
echo "• Restart your terminal application"
echo "• Configure your terminal to use a Nerd Font"
echo "• Enjoy your modern shell environment!"
echo
}
# Run main function
main "$@"