-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·139 lines (116 loc) · 5.28 KB
/
setup.sh
File metadata and controls
executable file
·139 lines (116 loc) · 5.28 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
#!/bin/bash
###############################################################################
# ERROR: Let the user know if the script fails
###############################################################################
# Exit handler - runs if script fails
trap 'if [ $? -ne 0 ]; then
echo -e "\n ❌ Mac setup failed"
exit $?
fi' EXIT
set -e
# Source utility functions
source ./scripts/utils.sh
chapter() {
local fmt="$1"
shift
printf "\n✦ ${bold}$((count++)). $fmt${normal}\n└─────────────────────────────────────────────────────○\n" "$@"
}
printf "Let's get started!\n"
###############################################################################
# CHECK: Internet
###############################################################################
chapter "Checking internet connection…"
check_internet_connection
###############################################################################
# PROMPT: Password
###############################################################################
chapter "Caching password…"
ask_for_sudo
###############################################################################
# INSTALL: Dependencies
###############################################################################
chapter "Installing Dependencies…"
# -----------------------------------------------------------------------------
# XCode
# -----------------------------------------------------------------------------
os=$(sw_vers -productVersion | awk -F. '{print $1 "." $2}')
if softwareupdate --history | grep --silent "Command Line Tools.*${os}"; then
print_success_muted 'Command-line tools already installed. Skipping'
else
step 'Installing Command-line tools...'
in_progress=/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
touch ${in_progress}
product=$(softwareupdate --list | awk "/\* Command Line.*${os}/ { sub(/^ \* /, \"\"); print }")
if ! softwareupdate --verbose --install "${product}"; then
echo 'Installation failed.' 1>&2
rm ${in_progress}
exit 1
fi
rm ${in_progress}
print_success 'Installation succeeded.'
fi
# -----------------------------------------------------------------------------
# Homebrew
# -----------------------------------------------------------------------------
if ! [ -x "$(command -v brew)" ]; then
step "Installing Homebrew…"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
export PATH=/opt/homebrew/bin:$PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>$HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
print_success "Homebrew installed!"
else
print_success_muted "Homebrew already installed. Updating Homebrew formulae…"
brew update --quiet >/dev/null 2>&1
fi
###############################################################################
# INSTALL: Homebrew Packages
###############################################################################
chapter "Installing Homebrew Packages…"
source ./scripts/brew.sh
###############################################################################
# INSTALL: Setup ZSH and oh-my-zsh
###############################################################################
chapter "Setting up ZSH…"
source ./scripts/zsh.sh
###############################################################################
# SETUP: Git
###############################################################################
chapter "Setting up Git…"
source ./scripts/git.sh
###############################################################################
# SETUP: SSH
###############################################################################
chapter "Setting up SSH…"
source ./scripts/ssh.sh
###############################################################################
# SETUP: Zshrc
###############################################################################
chapter "Setting up Zsh configuration…"
source ./scripts/zshrc.sh
###############################################################################
# SETUP: Fzf
###############################################################################
chapter "Setting up Fzf…"
source ./scripts/fzf.sh
###############################################################################
# SETUP: Alacritty
###############################################################################
chapter "Setting up Alacritty"
source ./scripts/alacritty.sh
###############################################################################
# SETUP: Development Tools with mise
###############################################################################
chapter "Setting up Development Tools…"
source ./scripts/mise.sh
###############################################################################
# SETUP: Mac Settings
###############################################################################
chapter "Setting up Mac Settings…"
source ./scripts/mac.sh
###############################################################################
# SETUP: Complete
###############################################################################
chapter "Setup Complete!"
print_success "Your Mac is now ready to use! 🎉"
print_success_muted "You may need to restart your computer for all changes to take effect."