-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
272 lines (235 loc) · 7.47 KB
/
install.sh
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
266
267
268
269
270
271
272
#!/usr/bin/env bash
#
# This script will install this custom Doom Emacs configuration
# WARNING Do not edit this file, it is generated by `install.org'
set -e
tty_escape() { printf "\033[%sm" "$1"; }
tty_mkbold() { tty_escape "1;$1"; }
tty_underline="$(tty_escape "4;39")"
tty_red="$(tty_mkbold 31)"
tty_green="$(tty_mkbold 32)"
tty_yellow="$(tty_mkbold 33)"
tty_blue="$(tty_mkbold 34)"
tty_purple="$(tty_mkbold 35)"
tty_bold="$(tty_mkbold 39)"
tty_reset="$(tty_escape 0)"
shell_join() {
local arg
printf "%s" "$1"
shift
for arg in "$@"; do
printf " "
printf "%s" "${arg// /\ }"
done
}
ohai() {
printf "${tty_purple}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
}
bullet() {
printf "${tty_green} ● ${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
}
error() {
printf "${tty_red}ERR${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
}
confirm_y() {
read -r -p "${tty_blue}${1:-Are you sure?} ${tty_bold}[Y/n]${tty_reset} " response
case "$response" in
[nN][oO]|[nN])
false
;;
*)
true
;;
esac
}
confirm_n() {
read -r -p "${tty_blue}${1:-Are you sure?} ${tty_bold}[y/N]${tty_reset} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
abort() {
error "${1:-Exiting}"
exit 1
}
cmd_missing() {
local cmd
cmd="$1"
if command -v "$cmd" &> /dev/null; then
false
else
true
fi
}
ohai "Checking for dependencies"
install_brew_dep() {
local package cmd
package="$1"
cmd="${2:-package}"
if cmd_missing "$cmd"; then
brew install "$package" > /dev/null 2>&1
bullet "Installed $package with homebrew"
else
brew upgrade "$package" > /dev/null 2>&1
bullet "Found $package"
fi
}
if cmd_missing brew; then
abort "Please install homebrew first! ${tty_underline}https://brew.sh${tty_reset}"
else
ohai "Found homebrew"
ohai "Updating..."
brew update > /dev/null 2>&1
fi
install_brew_dep git
install_brew_dep ripgrep rg
install_brew_dep fd
install_brew_dep cmake
install_brew_dep jq
if [[ $(uname -a) == "Darwin"*"arm64" ]]; then
error "Apple Silicon detected, please install ${tty_yellow}pandoc${tty_reset} and ${tty_yellow}shellcheck${tty_reset} manually"
else
install_brew_dep shellcheck
install_brew_dep pandoc
fi
if cmd_missing npm; then
error "npm is not installed. Check ${tty_yellow}doom doctor${tty_reset} after install for additional dependencies"
else
ohai "Installing npm dependencies"
cmd_missing stylelint && npm -g --silent install stylelint > "/dev/null" 2>&1
bullet "Installed stylelint with npm"
cmd_missing js-beautify && npm -g --silent install js-beautify > "/dev/null" 2>&1
bullet "Installed js-beautify with npm"
if ! cmd_missing asdf; then
ohai "Reshimming asdf shims"
asdf reshim
fi
fi
install_emacs="no"
if [ -d /Applications/Emacs.app ]; then
ohai "It looks like Emacs.app is already installed"
if confirm_n "Do you want to back it up and install Emacs Plus 29?"; then
test -d /Applications/Emacs-Backup.app && abort "Backup already exists"
\mv -iv /Applications/Emacs.app /Applications/Emacs-Backup.app
install_emacs="yes"
fi
else
ohai "Emacs is not installed. Let's install it before continuing"
if confirm_y "Install Emacs Plus 29?"; then
install_emacs="yes"
else
abort "You must install Emacs before continuing. Install it manually or run this program again."
fi
fi
if [[ $install_emacs = "yes" ]]; then
ohai "Installing Emacs. This might take a while..."
brew tap d12frosted/emacs-plus
brew install emacs-plus@29 --with-nobu417-big-sur-icon --with-native-comp
ohai "Copying to /Applications..."
\cp -ri "$(brew --prefix)/opt/emacs-plus@29/Emacs.app" /Applications/Emacs.app
fi
unset install_emacs
install_font() {
local regex fontname tarball target
regex="$1"
fontname="$2"
tarball="$3"
target="$4"
found=$(fd -IL -d 1 -t f "$regex" "$HOME/Library/Fonts" /Library/Fonts)
if [ -n "$found" ]; then
ohai "It looks like you already have $fontname font faces installed."
bullet "Skipping $fontname"
else
tar -zxf "resources/fonts/$tarball" -C "$target"
bullet "Installed $fontname"
fi
}
if confirm_y "Install Fonts?"; then
install_font '^sf.pro.*$' "SF Pro" "sf-pro.tar.gz" "/Library/Fonts/"
install_font '^fira.code.*$' "FiraCode" "firacode.tar.gz" "$HOME/Library/Fonts/"
install_font '^overpass.*$' "Overpass" "overpass.tar.gz" "$HOME/Library/Fonts/"
install_font '^bookerly.*$' "Bookerly" "bookerly.tar.gz" "$HOME/Library/Fonts/"
else
ohai "Ok, You can install them manually."
echo " There are links in ${tty_yellow}config.org${tty_reset} under ${tty_purple}Fonts${tty_reset}."
fi
elixir_ls_installed="no"
if [ -x "$HOME/.config/elixir-ls/release/launch.sh" ]; then
ohai "You already have elixir-ls installed. Skipping..."
else
if confirm_y "Do you want to setup the Elixir Language Server?"; then
if cmd_missing mix; then
error "You need to install elixir first!"
ohai "Skipping Elixir LS"
else
ohai "Cloning elixir-ls to $HOME/.config/elixir-ls"
git clone https://github.com/elixir-lsp/elixir-ls.git "$HOME/.config/elixir-ls" > /dev/null 2>&1
cd "$HOME/.config/elixir-ls"
ohai "Installing Deps"
mix deps.get > /dev/null
ohai "Compiling"
mix compile > /dev/null 2>&1
ohai "Building Release"
mix elixir_ls.release -o release > /dev/null 2>&1
cd - > /dev/null
export PATH="$PATH:$HOME/.config/elixir-ls/release"
elixir_ls_installed="yes"
fi
else
ohai "Ok, there are instructions in ${tty_yellow}readme.org${tty_reset} if you change your mind"
ohai "Skipping Elixir LS"
fi
fi
if confirm_y "Install DOOM?"; then
ohai "Installing DOOM"
emacs_config="$HOME/.emacs.d"
if [ -d "$emacs_config" ]; then
emacs_config_backup="$HOME/.emacs.backup"
ohai "You have an existing emacs configuration at ${tty_yellow}${emacs_config}${tty_reset}"
ohai "Backing up to ${tty_yellow}${emacs_config_backup}${tty_reset}"
test -d "$emacs_config_backup" && abort "You already have a backup. Please remove one of them and run this program again."
\mv -i "$emacs_config" "$emacs_config_backup"
unset emacs_config_backup
fi
git clone --depth 1 https://github.com/hlissner/doom-emacs "$emacs_config" >/dev/null
"${emacs_config}/bin/doom" install
"${emacs_config}/bin/doom" env
export PATH="$PATH:${emacs_config}/bin"
unset emacs_config
else
ohai "Skipping DOOM"
ohai "Skipping DOOM?"
ohai "Skipping DOOM ¯\_(ツ)_/¯"
fi
if [ ! -f secret.el ]; then
cp secret.example.el secret.el
ohai "Created $HOME/.config/doom/secret.el"
else
ohai "$HOME/.config/doom/secret.el already exists"
fi
ohai "Notes"
echo
echo "You should probably add ${tty_yellow}doom${tty_reset} to your path."
echo ' export PATH="$PATH:$HOME/.emacs.d/bin"'
echo
if [ "$elixir_ls_installed" = "yes" ]; then
echo "Since you installed Elixir LS, make sure that it is in your path."
echo ' export PATH="$PATH:$HOME/.config/elixir-ls/release"'
echo
echo " - If you have any issues, try running ${tty_yellow}doom env${tty_reset} and restarting emacs."
echo " - If that doesn't work, refer to ${tty_blue}readme.org${tty_reset}."
echo
fi
echo "Also, now would be a great time to run"
echo " ${tty_yellow}doom doctor${tty_reset}"
echo
echo "Finally, you should edit $HOME/.config/doom/secret.el and add your name and email"
echo
echo "After that, open Emacs.app in your Applications folder and you're good to go!"
echo " Enjoy! - Adam"
unset elixir_ls_installed