-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
315 lines (275 loc) · 7.3 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#!/bin/bash
set -e
# Utility functions
## For ease of iterative experimentation
doo () {
$@
# echo $@
}
command_exists () {
type "$1" &> /dev/null ;
}
is_osx () {
if [ "$(uname)" == "Darwin" ]; then
true
else
false
fi
}
installed () {
echo -e " ✓ $1 already installed."
}
errm () {
2>&1 echo -e "$@"
}
# START HERE.
main () {
cd $HOME
install_zsh
install_rg
install_universal_ctags
setup_ctags
install_plug
install_tmux
install_tpm
setup_tmux_clipboard
install_tmuxinator
confirm_no_clobber
confirm_have_goodies
install_scm_breeze
install_diff-so-fancy
install_neovim
install_alacritty
for i in ${DOTS[@]}; do
link_dot $i
done
setup_git_global_ignore
# TODO: Make sure permissions are legit.
}
install_zsh() {
if !(command_exists zsh); then
doo apt-get install zsh --assume-yes
doo chsh -s /bin/zsh
else
installed 'zsh'
fi
# Install oh-my-zsh
DIR="/Users/$USER/.oh-my-zsh"
if [ ! -d "$DIR" ]; then
# https://github.com/ohmyzsh/ohmyzsh#unattended-install
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
# Remove zshrc created by oh-my-zsh by default because we have our own
doo rm -rf ~/.zshrc
# Setup theme in oh-my-zsh
doo cp "$EXPORT_DIR/themes/clean-minimal.zsh-theme" ~/.oh-my-zsh/themes/clean-minimal.zsh-theme
else
installed 'oh-my-zsh'
fi
}
install_universal_ctags () {
if !(command_exists uctags); then
# requirements
if !(command_exists automake); then
doo arch -arm64 brew install automake
fi
if !(command_exists pkg-config); then
doo arch -arm64 brew install pkg-config
fi
if !(command_exists libxml2); then
doo arch -arm64 brew install libxml2
fi
# Troubleshooting tips: If "error undefined macro AC_MSG_ERRO" error
# https://github.com/pooler/cpuminer/issues/74
# doo sudo apt-get install libcurl4-openssl-dev --assume-yes
doo git clone https://github.com/universal-ctags/ctags.git
doo cd ctags
doo ./autogen.sh
doo ./configure --program-prefix=u
doo make
# If fails for ex: in docker, try removing sudo
doo sudo make install
doo cd ..
doo rm -rf ctags
else
installed 'Universal-ctags'
fi
}
setup_ctags () {
SRC="git_template"
DEST=.$SRC
if [ ! -d ".$SRC" ]; then
git config --global init.templatedir '~/.git_template'
git config --global alias.ctags '!.git/hooks/ctags'
doo cp -R $EXPORT_DIR/$SRC $DEST
else
installed 'ctags git hooks'
fi
}
# ripgrep search, faster than ack, ag, silver surfer etc.
# Used by vim.ack plugin to do searching words in a project
install_rg () {
if !(command_exists rg); then
doo arch -arm64 brew tap burntsushi/ripgrep https://github.com/BurntSushi/ripgrep.git
doo arch -arm64 brew install burntsushi/ripgrep/ripgrep-bin
else
installed 'rg'
fi
}
# Install plug for first time if .vim directory doesn't exist
install_plug() {
FILE=".vim/autoload/plug.vim"
if [ ! -f "$FILE" ]; then
doo curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
else
installed 'Plug'
fi
}
install_tmux () {
if !(command_exists tmux); then
doo arch -arm64 brew install tmux
else
installed 'tmux'
fi
}
install_tpm() {
DIR=".tmux/plugins/tpm"
if [ ! -d "$DIR" ]; then
doo git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins
else
installed 'TPM'
fi
}
setup_tmux_clipboard() {
if is_osx && !(command_exists reattach-to-user-namespace); then
doo arch -arm64 brew install reattach-to-user-namespace
fi
}
install_tmuxinator () {
# Tmuxinator requires a higher ruby version
# Using rbenv to manage ruby version for the root directory
if !(command_exists rbenv); then
doo arch -arm64 brew install rbenv
doo rbenv install 2.6.3
doo rbenv local 2.6.3
else
installed 'rbenv'
fi
if !(command_exists tmuxinator); then
doo sudo gem install tmuxinator
else
installed 'tmuxinator'
fi
}
# Subroutines
confirm_no_clobber() {
NOTADOT=''
for i in ${DOTS[@]}; do
dst=.$i
if [ ! -L $dst -a -e $dst ]; then
NOTADOT="${NOTADOT}$dst "
fi
done
if [ -n "$NOTADOT" ]; then
errm "\n ABORT"
errm "\n These exist but are not symlinks:"
errm " $NOTADOT"
exit 2
fi
}
confirm_have_goodies() {
NOFINDINGS=''
if [ ! -e "$EXPORT_DIR" ]; then
errm "\n ABORT\n\n Where are we copying files from?"
errm " Couldn't find export dir: '$EXPORT_DIR'"
exit 2
fi
for i in ${DOTS[@]}; do
goody="$EXPORT_DIR/$i"
# Exists, is readable?
if [ ! -r "$goody" ]; then
NOFINDINGS="${NOFINDINGS}$i"
# Searchable if directory?
elif [ -d "$goody" -a ! -x "$goody" ]; then
NOFINDINGS="${NOFINDINGS}$i"
fi
done
if [ -n "$NOFINDINGS" ]; then
errm "\n ABORT\n\n These add-ons do not exist in a state we can use!"
errm " $NOFINDINGS"
exit 2
fi
}
install_scm_breeze() {
DIR='scm_breeze'
if [ ! -d ".$DIR" ]; then
doo git clone git://github.com/scmbreeze/scm_breeze.git ~/.scm_breeze
doo ~/.scm_breeze/install.sh
else
installed 'scm_breeze'
fi
}
install_diff-so-fancy() {
if !(command_exists diff-so-fancy); then
doo arch -arm64 brew install diff-so-fancy
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --bool --global diff-so-fancy.markEmptyLines false
else
installed 'diff-so-fancy'
fi
}
install_neovim() {
if !(command_exists nvim); then
doo arch -arm64 brew install neovim/neovim/neovim
doo ln -s ~/.vim ~/.config/nvim
doo ln -s ~/.vimrc ~/.config/nvim/init.vim
else
installed 'neovim'
fi
}
# https://github.com/alacritty/alacritty#macos
# Alacritty helpful links:
# Setup italics: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/
# Ligature for operator mono: https://github.com/kiliman/operator-mono-lig
install_alacritty() {
if !(command_exists alacritty); then
doo arch -arm64 brew cask install alacritty
# clone
doo git clone https://github.com/alacritty/alacritty.git
doo cd alacritty
# Install terminfo globally
doo sudo tic -xe alacritty,alacritty-direct extra/alacritty.info
# clean
doo cd ..
doo rm -rf alacritty
# Symlink config file
doo mkdir -p .config/alacritty
doo ln -s "$EXPORT_DIR/config/alacritty.yml" ~/.config/alacritty/alacritty.yml
# Enable smoothing on mac
doo defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
doo defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
else
installed 'alacritty'
fi
}
link_dot() {
src=$1
dst=.$1
doo rm -f $dst
doo ln -s $EXPORT_DIR/$src $dst
}
setup_git_global_ignore() {
doo git config --global core.excludesfile ~/.gitignore_global
}
# Initialize globals
EXPORT_DIR=$(dirname "${PWD}/$0")
DOTS=(
vimrc
zshrc
tmux.conf
tmux-osx.conf
tern-config
ackrc
gitignore_global
)
# Invoke
main