-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.zsh
executable file
·160 lines (133 loc) · 4.49 KB
/
setup.zsh
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
#!/usr/bin/env zsh
export IS_AIR="false"
export IS_MINI="false"
export IS_WORK="true"
export DOTFILES="$HOME/Repos/ooloth/dotfiles"
handle_error() {
local exit_code="$1"
local line_number="$2"
printf "\nError on line $line_number: Command exited with status $exit_code.\n"
exit "$exit_code"
}
# Trap ERR signals and call handle_error()
trap 'handle_error $? $LINENO' ERR
###########
# CONFIRM #
###########
printf "\nWelcome to your new Mac! This installation will perform the following steps:\n\n"
printf "1. Confirm this is a Mac\n"
printf "2. Ask you to enter your password\n"
printf "3. Confirm the Command Line Developer Tools are installed\n"
printf "4. Clone ooloth/dotfiles\n"
printf "5. Create your SSH keys\n"
printf "6. Confirm you can SSH to GitHub\n"
printf "7. Install Homebrew\n"
printf "8. Install the packages, casks, App Store apps and VS Code extensions listed in your Brewfile\n"
printf "9. Configure your Mac to use the Homebrew version of Zsh\n"
printf "10. Install rust (if not work computer)\n"
printf "11. Install uv\n"
printf "12. Install the latest version of Node via fnm and set it as the default\n"
printf "13. Install global npm dependencies\n"
printf "14. Install tmux dependencies\n"
printf "15. Install neovim dependencies\n"
printf "16. Install yazi flavors (if not work computer)\n"
printf "17. Symlink your dotfiles to your home and library directories\n"
printf "18. Update macOS system settings\n\n"
vared -p "Sound good? (y/N) " -c key
if [[ ! "$key" == 'y' ]]; then
printf "\nNo worries! Maybe next time."
printf "\nExiting..."
exit 1
else
printf "\nExcellent! Here we go...\n\n"
fi
#################
# PREREQUISITES #
#################
printf "Verifying prerequisites...\n\n"
# This is a Mac
printf "Confirming this is a Mac...\n"
if [ "$(uname)" != "Darwin" ]; then
printf "Oops, it looks like this is a non-UNIX system. This script only works on a Mac.\n\nExiting..."
exit 1
fi
printf "This is a Mac. But you knew that already.\n\n"
# You know this Mac's password
printf "Confirming you are authorized to install things on this Mac...\n\n"
sudo -v
# Keep-alive: update existing `sudo` time stamp until setup has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
printf "Yup. That's the password.\n\n"
# The Command Line Tools are installed
# printf "Confirming the Command Line Tools are installed...\n\n"
#
# if [ ! -d "$HOME/Library/Developer/CommandLineTools" ]; then
# printf "Apple's command line developer tools must be installed before running this script. Installing now.\n"
# xcode-select --install
#
# if [ ! -d "$HOME/Library/Developer/CommandLineTools" ]; then
# printf "\nOops, it looks like the Xcode CLI tools are still not installed. Please install and try again.\n"
# exit 1
# else
# printf "\nXcode CLI tools are now installed.\n"
# fi
# else
# printf "\nXcode CLI tools are already installed.\n"
# fi
##################
# CLONE DOTFILES #
##################
if [ -d "$DOTFILES" ]; then
printf "📂 Dotfiles are already installed. Pulling latest changes.\n"
cd "$DOTFILES"
git pull
else
# Otherwise, clone via https (will be converted to ssh by install/github.zsh)
printf "📂 Installing dotfiles"
mkdir -p "$DOTFILES"
git clone "https://github.com/ooloth/dotfiles.git" "$DOTFILES"
fi
# # Add all the helpers the install scripts below will reference
# source "$DOTFILES/config/zsh/aliases.zsh"
# source "$DOTFILES/config/zsh/utils.zsh"
###########
# INSTALL #
###########
cd "$DOTFILES/bin/install"
source ssh.zsh
source github.zsh
source homebrew.zsh
source "$DOTFILES/bin/update/homebrew.zsh"
source zsh.zsh
source rust.zsh
source uv.zsh
source node.zsh
source "$DOTFILES/bin/update/npm.zsh"
source tmux.zsh
source neovim.zsh
source yazi.zsh
source content.zsh
source "$DOTFILES/bin/update/symlinks.zsh"
source settings.zsh
# TODO: automate my remaining manual setup steps (e.g. app preferences, etc.)
###################
# SUGGEST RESTART #
###################
source "$DOTFILES/config/zsh/utils.zsh"
info "🎉 Setup complete!"
printf "\nCongratulations! Your Mac is nearly set up.\n\n"
printf "To apply your your preferences, your computer needs to restart.\n\n"
vared -p "Are you ready to restart now (recommended)? (y/N) " -c restart_choice
if [[ "$restart_choice" = 'y' ]]; then
printf "\nExcellent choice.\n"
printf "\nRestarting..."
sudo shutdown -r now
else
printf "\nNo worries! Your terminal session will now refresh...\n"
exec -l $SHELL
printf "\nDone. Enjoy your new Mac!\n"
fi