-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·204 lines (160 loc) · 6.18 KB
/
install
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
#!/bin/bash
set -e
cd "$(dirname "$0")"
source lib/arch.sh
source lib/print.sh
source lib/run.sh
say-loud "Welcome to dxw!"
say "Let's get you set up"
say "This may take a while..."
say "You might want to find something else to do while we do this"
say "But don't go away completely! You'll need to do things at points"
if ! ask_yN "Are you ready?"; then
say-loud "Goodbye!"
exit 1
fi
if ! macos; then
instruct "It looks like you're not running this in macOS"
instruct "We don't support other operating systems, sorry!"
exit 1
fi
# Begin Rosetta
if m1; then
say "It looks like you're on a Mac with Apple silicon"
say-loud "Installing the Intel compatibility layer, Rosetta"
say "You might be asked for your login password and to agree to terms and conditions..."
run 'arch -arm64e softwareupdate --install-rosetta'
fi
# End Rosetta
# Begin Homebrew
if m1; then
say-loud "Installing Homebrew for Apple silicon software"
say "You might be asked for your login password and to confirm"
say "Once you've confirmed, this might take a few minutes..."
# shellcheck disable=SC2016
run 'arch -arm64e /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
say-loud "Installing Homebrew for Intel software"
say "You might be asked for your login password and to confirm"
say "Once you've confirmed, this might take a few minutes..."
# shellcheck disable=SC2016
run 'arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
else
say-loud "Installing Homebrew"
say "You might be asked for your login password and to confirm"
say "Once you've confirmed, this might take a few minutes..."
# shellcheck disable=SC2016
run '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
fi
say-loud "Configuring Homebrew for the rest of this install..."
if m1; then
eval "$(/usr/local/bin/brew shellenv)"
eval "$(/opt/homebrew/bin/brew shellenv)"
else
eval "$(/usr/local/bin/brew shellenv)"
fi
instruct "Homebrew manages software on your machine for you"
instruct "Try to use it when you need to install new things"
instruct "It will make keeping them up to date easier"
instruct "You can install most apps using it too!"
say "See https://brew.sh/ for more information about Homebrew"
pause
# End Homebrew
# Begin dependencies via Homebrew
say-loud "Installing recommended packages and apps with Homebrew"
say "You might be asked for your login password"
say "This might take a while..."
run_with_retry 'brew bundle install --no-lock --verbose'
pause
# End dependencies via Homebrew
# Begin Nerd Font
say-loud "Installing Fira Code Nerd Font"
say-loud "This adds support for icons used in custom prompts"
say-loud "E.g. Starship, which was installed via Homebrew"
say-loud "You might be asked for permission to modify your Terminal settings"
run_with_retry 'echo "tell app \"Terminal\" to set font name of settings set \"Basic\" to \"FiraCodeNerdFontComplete-Retina\"" | osascript;'
DEFAULT_ITERM2=
if ! [ -f ~/Library/Preferences/com.googlecode.iterm2.plist ]; then
DEFAULT_ITERM2=1
elif ask_Yn "Do you want to overwrite your existing iTerm2 settings (to apply the font)?"; then
DEFAULT_ITERM2=1
say-loud "Creating a backup..."
run 'mv ~/Library/Preferences/com.googlecode.iterm2.plist ~/Library/Preferences/com.googlecode.iterm2.plist.bak'
fi
if [ -n "$DEFAULT_ITERM2" ]; then
say-loud "Creating default iTerm2 settings..."
run 'cp src/com.googlecode.iterm2.plist ~/Library/Preferences/com.googlecode.iterm2.plist'
fi
# End Nerd Font
# Begin ZSH
say-loud "Setting ZSH as the default shell"
say "You might be asked for your login password..."
if ! sudo grep "$(brew --prefix)/bin/zsh" /etc/shells; then
# shellcheck disable=SC2016
run 'echo "$(brew --prefix)/bin/zsh" | sudo tee -a /etc/shells'
fi
# shellcheck disable=SC2016
run 'chsh -s "$(brew --prefix)/bin/zsh" "$USER"'
DEFAULT_ZSHRC=
if ! [ -f ~/.zshrc ]; then
DEFAULT_ZSHRC=1
elif ask_Yn "Do you want to overwrite your existing ZSH config?"; then
DEFAULT_ZSHRC=1
say-loud "Creating a backup..."
run 'mv ~/.zshrc ~/.zshrc.bak'
fi
if [ -n "$DEFAULT_ZSHRC" ]; then
say-loud "Creating default ZSH config..."
run 'cp src/zshrc ~/.zshrc'
fi
# End ZSH
# Begin choices
instruct "Now you'll need to answer some questions about preferences"
instruct "Don't know what a question is asking about?"
instruct "You probably want the default option"
instruct "(Press return without giving an answer)"
HEADLESS_POSTGRESQL=
if ask_Yn "Are you content with running Postgresql as a headless service?"; then
HEADLESS_POSTGRESQL=1
say-loud "Installing Postgresql..."
say "You might be asked for your login password..."
brew install postgresql
brew services start postgresql
else
say-loud "Installing Postgres.app..."
say "You might be asked for your login password..."
brew install postgres-unofficial
fi
if [ -n "$DEFAULT_ZSHRC" ] && ! ask_Yn "Are you content with using nano as your 'EDITOR'?"; then
ask "What should we set 'EDITOR' to? [command name only, not a path]"
sed -i '' 's/export EDITOR=nano/export EDITOR="'"$REPLY"'"/' ~/.zshrc
instruct "You might want to check '$REPLY' is installed after we're done."
fi
# End choices
say-loud "We're done!"
say "We installed Homebrew for installing and managing most software"
if m1; then
if [ -n "$DEFAULT_ZSHRC" ]; then
say "We installed Intel Homebrew as a backup (aliased as 'ibrew')"
else
say "We installed Intel Homebrew as a backup"
fi
fi
say "We installed the following packages:"
echo
awk '/^brew /{print}' Brewfile | sort | sed -r 's,^brew "(.+)".*$,\1\n https://formulae.brew.sh/formula/\1\n,'
say "We installed the following applications:"
echo
awk '/^cask /{print}' Brewfile | sort | sed -r 's,^cask "(.+)".*$,\1\n https://formulae.brew.sh/cask/\1\n,'
if [ -n "$HEADLESS_POSTGRESQL" ]; then
say "We installed Postgresql as a service"
else
say "We installed Postgres.app"
fi
if [ -n "$DEFAULT_ZSHRC" ]; then
say "We set ZSH as the default shell with some default configuration"
else
say "We set ZSH as the default shell"
fi
pause
instruct "Quit your terminal when you're done"
say "You might like to use the newly installed iTerm.app in future"