-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·368 lines (324 loc) · 8.24 KB
/
install.sh
File metadata and controls
executable file
·368 lines (324 loc) · 8.24 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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#!/bin/bash
#
# Link all the regular files in dotfiles/home/ into ~, with a '.' prefix
#
# For example, dotfiles/home/profile --> ~/.profile
# dotfiles/home/tmux --> ~/.tmux
#set -o xtrace
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; echo "$PWD")
# ye olde toole shoppe
library='
info
quiet
clone_update
'
for tool in $library
do
source "$here/library/$tool.sh"
done
error() {
echo "$(basename ${BASH_SOURCE[0]}) error: $*" >&2
exit 1
}
install_bash()
{
# use Bash as default shell
if [ "$SHELL" != '/bin/bash' ]; then
chsh -s /bin/bash
exec -l /bin/bash
fi
}
install_deps()
{
for pkg in git curl jq
do
info "installing dependency: ${pkg}"
"$here/scripts/pkg_install.sh" "$pkg"
done
}
install_dotfiles()
{
quiet pushd $here/home
local symbolic # whether to make symlinmks. systemd hates them!
echo "Linking files from $here/home into $HOME"
for file in $(find * -maxdepth 0 -type f); do
[[ -d $(dirname $file) ]] && symbolic='-s' || symbolic=''
mkdir -p "$(dirname ~/."$file")"
ln -v -f "$symbolic" "$PWD/$file" ~/."$file"
done
quiet popd
}
install_bash_completion()
{
# Install base bash-completion with fewer bugs
"$here/scripts/bash_completion.sh"
# Install other Bash completions we have collected
for completion_script in "$here"/scripts/bash_completion.d/*.sh
do
"$completion_script"
done
}
install_aliases()
{
# Curtis Allen's kctx trick
"$here/scripts/kctx.sh"
}
install_lscolors()
{
# LS_COLORS is used by readline when `set colored-stats on` is set
# grab about 300 different colors for different filetypes
"$here/scripts/lscolors_install.sh"
}
install_prompt()
{
# an informative git prompt for Bash
"$here/scripts/gitprompt_install.sh"
}
install_fonts()
{
# firacode, fixed-width coding font with ligatures
"$here/scripts/firacode_font_install.sh"
case $OSTYPE in
darwin*)
open "$here/init/darwin/Big Ol Code.terminal"
sudo -u "$USER" defaults write com.apple.Terminal.plist "Default Window Settings" "Big Ol Code"
sudo -u "$USER" defaults write com.apple.Terminal.plist "Startup Window Settings" "Big Ol Code"
;;
*)
;;
esac
}
configure_git_ssh_keysigning()
{
git config --global gpg.format ssh
# shellcheck disable=SC2088
git config --global user.signingkey '~/.ssh/id_1password.pub'
}
configure_git()
{
configure_git_ssh_keysigning
# show word differences in markdown (*.md) files when you run `git diff`
"$here/scripts/git_markdown_word_diff.sh"
}
install_sublimetext()
{
local settings
# install sublimetext user settings
case $OSTYPE in
darwin*)
subl_dir='/Applications/Sublime Text.app/Contents/SharedSupport/bin'
user_dir=$HOME/Library/Application\ Support/Sublime\ Text\ 3/Packages/User
user_keymap=$user_dir/Default\ \(OSX\).sublime-keymap
;;
linux*)
bin_path=/usr/bin
user_dir=$HOME/.config/sublime-text-3/Packages/User
user_keymap=$user_dir/Default\ \(Linux\).sublime-keymap
;;
*)
echo >&2 "Don't know how to install sublimetext on ${OSTYPE}!"
return 1
esac
if ! command -v subl
then
case $OSTYPE in
linux*)
echo "Installing sublimetext from apt repo"
./scripts/sublimetext_install.sh
;;
*)
echo "Sublimetext is not installed, skipping configuration"
return 0
esac
fi
if ! command -v subl && ! grep -q "${subl_dir}" "$HOME/.profile"
then
echo "Adding Sublime Text bin dir to PATH: ${subl_dir}"
export PATH="$PATH:${bin_path}"
cat <<EOF >>"$HOME/.profile"
# add sublime text bin to path
if [ -d '${subl_dir}' ]
then
export PATH="\$PATH:${subl_dir}"
fi
EOF
# now import the path
source ~/.profile
fi
subl -v # print Sublime Text version
echo "SublimeText User dir: $user_dir"
mkdir -p "$user_dir"
quiet pushd sublime
for settings in ./*.sublime-settings
do
cp "$settings" "${user_dir}/${settings}"
done
cp sublime-keymap "$user_keymap"
quiet popd
}
install_vim()
{
# vim itself
if ! command -v vim &>/dev/null || ! grep -q "+python3" <(vim --version)
then
case $OSTYPE in
darwin*)
"$here/scripts/pkg_install.sh" cmake macvim
#error "Install macvim according to: https://github.com/ycm-core/YouCompleteMe#macos"
;;
*)
# Debian has vim with python plugin support in vim-nox package
vim='vim'
if os_id=$(source /etc/os-release; echo $ID) && [[ "$os_id" = debian ]]
then
vim='vim-nox'
fi
"$here/scripts/pkg_install.sh" $vim
if ! grep -q "+python3" <(vim --version)
then
error "vim missing python3 plugin support. Install vim according to: https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source"
fi
;;
esac
fi
# tools needed
"$here/scripts/pkg_install.sh" git cmake
"$here/scripts/g++_install.sh"
# TODO: fix the broken vim pathogen and plugin situation
# # the ~/.vim file has a line to autoload pathogen, which will autoload all plugins
# # that we install to ~/.vim/bundle
# # so we install pathogen, and some plugins, there
# mkdir -p "$HOME/.vim/bundle"
# quiet pushd "$HOME/.vim/bundle"
# echo "Installing vim plugins to $PWD"
# TODO: fix the broken vim pathogen and plugin situation
# # vim-markdown
# git clone git://github.com/plasticboy/vim-markdown.git
# TODO: fix the broken vim pathogen and plugin situation
# # vim-javscript, for better ES6 highlighting
# git clone git://github.com/pangloss/vim-javascript.git
# TODO: fix the broken vim pathogen and plugin situation
# # vim-gitgutter, show git diff in gutter (left-most column)
# git clone git://github.com/airblade/vim-gitgutter.git
# quiet popd
# # YouCompleteMe programmatic text completion
# $here/scripts/youcompleteme_install.sh
}
install_editors()
{
install_vim
"$here/scripts/joplin_install.sh"
}
install_toolchains()
{
install_node
install_go
install_rust
install_python
}
install_node()
{
if ! command -v nvm
then
info "installing nvm"
quiet "$here/scripts/nvm_install.sh"
fi
if ! command -v yarn
then
info "installing yarn"
quiet "$here/scripts/yarn_install.sh"
fi
source ~/.profile
if ! command -v node
then
if ! nvm use --lts
then
nvm install --lts
fi
fi
}
install_go()
{
printf "Checking Golang: "
if ! command -v go
then
info "Installing Golang"
"$here/scripts/go_install.sh"
fi
}
install_rust()
{
printf "Checking Rust: "
if ! command -v cargo
then
info "Installing Rust"
"$here/scripts/rust_install.sh"
fi
}
install_python()
{
info "Installing Python"
"$here/scripts/uv-install.sh"
}
install_tools()
{
# TODO: Fix
# if ! command -v cfssl
# then
# "$here/scripts/cfssl_install.sh"
# fi
# TODO: Fix
# # mycli is a mysql command line interface with smart tab completion
# pip install mycli
# git lfs (large file support) is used to store references to huge files
"$here/scripts/gitlfs_install.sh"
# neofetch is a system info display tool
"$here/scripts/neofetch_install.sh"
"$here/scripts/pkg_install.sh" htop
}
disable_unwanted_devices()
{
case "$OSTYPE" in
linux*)
for rule in init/linux/udev/rules.d/*
do
sudo ln -s $(readlink -f "$rule") /etc/udev/rules.d/
done
# must reload the udev rules after installing new ones
sudo udevadm control --reload-rules
# tip: `udevadm monitor` can help debug rules
;;
esac
}
# install everything, if we are not being sourced
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
install_bash
install_deps
install_dotfiles
install_bash_completion
install_aliases
install_lscolors
install_prompt
install_fonts
configure_git
# are we in a graphical session? if so, install sublimetext and rescuetime
case "$OSTYPE" in
linux*)
if ! [ -z ${XDG_CURRENT_DESKTOP+x} ]
then
install_sublimetext
"$here/scripts/rescuetime_setup.sh"
else
echo "non-graphical session (XDG_CURRENT_DESKTOP not defined), skipping sublimetext and rescuetime"
"$here/scripts/pkg_install.sh" ranger
fi
;;
darwin*)
brew install rescuetime
;;
esac
install_editors
install_toolchains
source ~/.profile
install_tools
fi