-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-unix.sh
executable file
·465 lines (390 loc) · 12.8 KB
/
setup-unix.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
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#!/bin/bash
source $(dirname $0)/setup-unix-functions.sh
# ------------------------------------------------------------------------------
# Parse input parameters
# ------------------------------------------------------------------------------
if [ -z "$EMAIL" ]; then
echo "Error: EMAIL is not set. Aborting script."
exit 1
fi
# ------------------------------------------------------------------------------
# Install Oh My ZSH
# ------------------------------------------------------------------------------
if [[ ! -d "$HOME/.oh-my-zsh" ]]; then
log "Installing Oh My ZSH"
CHSH=no KEEP_ZSHRC=no RUNZSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# ------------------------------------------------------------------------------
# Install dirs
# ------------------------------------------------------------------------------
log "Creating directories"
mkdir -p $DIR_DOWNLOADS
mkdir -p $DIR_SCRIPTS
mkdir -p $DIR_TOOLS
# ------------------------------------------------------------------------------
# Install config
# ------------------------------------------------------------------------------
log "Configuring aliases"
cp alias.sh $DIR_SCRIPTS
log "Configuring common shell setup"
# ------------------------------------------------------------------------------
# .shell_common
# ------------------------------------------------------------------------------
cat << EOF > ~/.shell_common
# aliases
source $DIR_SCRIPTS/alias.sh
# terminal
export HISTSIZE=100000
export HISTFILESIZE=100000
export EDITOR=hx
export VISUAL=hx
# windows
export APPDATA=/mnt/c/Users/Renato/AppData/Roaming/
export LOCALAPPDATA=/mnt/c/Users/Renato/AppData/Local/
# homebrew
export PATH=\$PATH:$(brew_dir)/bin
export PATH=\$PATH:$(brew_dir)/sbin
export LIBRARY_PATH=$(brew_dir)/lib
export LD_LIBRARY_PATH=$(brew_dir)/lib
export CMAKE_LIBRARY_PATH=$(brew_dir)/lib
export CMAKE_SYSTEM_LIBRARY_PATH=$(brew_dir)/lib
export PKG_CONFIG_PATH=$(brew_dir)/lib/pkgconfig
export CPATH=$(brew_dir)/include
# langs
export PATH=\$PATH:$HOME/go/bin
export PATH=\$PATH:$HOME/.cargo/bin
# custom tools
export PATH=\$PATH:$DIR_TOOLS
export PATH=\$PATH:$DIR_TOOLS/FlameGraph
# system
ulimit -n 65365
# ssh
pkill ssh-agent
eval "\$(ssh-agent -s)"
ssh-add $HOME/.ssh/dinhani
# asdf
source $(brew_dir)/opt/asdf/libexec/asdf.sh
EOF
# ------------------------------------------------------------------------------
# .bashrc
# ------------------------------------------------------------------------------
log "Configuring .bash_profile"
cat << EOF > ~/.bash_profile
source ~/.bashrc
EOF
log "Configuring .bashrc"
cat << EOF > ~/.bashrc
# common
source ~/.shell_common
# completions
for COMPLETION in "$(brew_dir)/etc/bash_completion.d/"*
do
source "\${COMPLETION}"
done
# starship
eval "\$(starship init bash)"
# zoxide
eval "\$(zoxide init bash)"
EOF
# ------------------------------------------------------------------------------
# .zshrc
# ------------------------------------------------------------------------------
log "Configuring .zshrc"
cat << EOF > ~/.zshrc
# common
source ~/.shell_common
# oh-my-zsh
export ZSH=$HOME/.oh-my-zsh
source $HOME/.oh-my-zsh/oh-my-zsh.sh
# ls colors
export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"
zstyle ':completion:*' list-colors \${(s.:.)LS_COLORS}
# starship
eval "\$(starship init zsh)"
# zoxide
eval "\$(zoxide init bash)"
EOF
reload
# ------------------------------------------------------------------------------
# Install APT basic tools
# ------------------------------------------------------------------------------
if is_linux; then
log "Updating APT repositories"
sudo apt update
log "Upgrading APT software"
sudo apt upgrade -y
log "Installing APT build tools"
install_apt build-essential
install_apt curl
fi
# ------------------------------------------------------------------------------
# Install Homebrew
# ------------------------------------------------------------------------------
if not_installed "brew"; then
log "Installing Homebrew"
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
reload
fi
# ------------------------------------------------------------------------------
# Install build tools
# ------------------------------------------------------------------------------
log "Installing build tools"
install_brew autoconf
install_brew bison
install_brew cmake
install_brew flex
install_brew gcc
install_brew gcc@11
install_brew gcc@12
install_brew gcc@13
install_brew gettext
install_brew just
install_brew llvm
install_brew make
install_brew re2c
# ------------------------------------------------------------------------------
# Install CLI tools
# ------------------------------------------------------------------------------
log "Installing CLI tools"
# shells
install_brew bash
install_brew nushell
install_brew zsh
install_brew starship
# managers
install_brew asdf
install_brew mise
# other
install_brew bat
install_brew dasel
install_brew erdtree
install_brew eza
install_brew fd
install_brew fzf
install_brew gitql
install_brew gnupg
install_brew graphviz
install_brew helix
install_brew htmlq
install_brew htop
install_brew imagemagick
install_brew jq
install_brew killport
install_brew lazydocker
install_brew lazygit
install_brew pandoc
install_brew ripgrep
install_brew rust
install_brew sd
install_brew speedtest-cli
install_brew subversion
install_brew unzip
install_brew util-linux
install_brew valgrind
install_brew w3m
install_brew websocat
install_brew zoxide
# linux specific
if is_linux; then
install_apt heaptrack
install_apt heaptrack-gui
install_brew sysstat
fi
# ------------------------------------------------------------------------------
# Install languages / build tools
# ------------------------------------------------------------------------------
brew tap oven-sh/bun
install_brew bazelisk
install_brew bun
install_brew clojure
install_brew crystal
install_brew dmd
install_brew dotnet
install_brew dub
install_brew elixir
install_brew erlang
install_brew gleam
install_brew go
install_brew gradle
install_brew groovy
install_brew haskell-stack
install_brew julia
install_brew kotlin
install_brew leiningen
install_brew lua
install_brew maven
install_brew node@22
install_brew ocaml
install_brew odin
install_brew openjdk
install_brew perl
install_brew powershell
install_brew protobuf
install_brew python
install_brew r
install_brew racket
install_brew rakudo
install_brew ruby
install_brew rustup
install_brew scala
install_brew solidity
install_brew vlang
install_brew zig
# ------------------------------------------------------------------------------
# Install languages extensions
# ------------------------------------------------------------------------------
# Golang
log "Installing Golang extensions"
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/nametake/golangci-lint-langserver@latest
go install golang.org/x/tools/gopls@latest
# Python
log "Installing Python extensions and tools"
pip3 install --break-system-packages bs4 dpath httpie lxml matplotlib mycli networkx numpy pandas polars pgcli python-lsp-server requests ruff scipy selenium unidecode toml tomli yamale yapf
# Ruby
log "Installing Ruby extensions and tools"
gem install --conservative activesupport eth pry nokogiri pp puma rails rufo sinatra solargraph webrick tomlrb tomlib
# Rust
log "Installing Rust toolchains"
rustup toolchain install stable
rustup toolchain install nightly
rustup component add clippy
rustup component add rustfmt
rustup component add rust-analyzer
rustup +nightly component add clippy
rustup +nightly component add rustfmt
rustup +nightly component add rust-analyzer
log "Installing Rust extensions"
cargo install cargo-expand
cargo install wait-service
# ------------------------------------------------------------------------------
# Install VSCode extensions
# ------------------------------------------------------------------------------
# General
# WSL / SSH
install_vscode ms-vscode-remote.remote-wsl # WSL
install_vscode ms-vscode-remote.remote-ssh # SSH
# General
install_vscode github.copilot # Copilot
install_vscode dinhani.divider # Divider
install_vscode vscode-icons-team.vscode-icons # Icons
install_vscode oderwat.indent-rainbow # Indent Rainbow
install_vscode danbackes.lines # Lines
# Language / tools
install_vscode EditorConfig.EditorConfig # .editorconfig
install_vscode mechatroner.rainbow-csv # CSV
install_vscode golang.Go # Go
install_vscode ZainChen.json # JSON
install_vscode yzhang.markdown-all-in-one # Markdown
install_vscode ms-vscode.PowerShell # PowerShell
install_vscode rust-lang.rust-analyzer # Rust
install_vscode tamasfe.even-better-toml # TOML
# ------------------------------------------------------------------------------
# Install pre-compiled tools
# ------------------------------------------------------------------------------
if not_installed "flamegraph.pl"; then
log "Installing FlameGraph"
rm -rf $DIR_DOWNLOADS/FlameGraph
git clone https://github.com/dinhani/FlameGraph-RustTheme $DIR_DOWNLOADS/FlameGraph
cp -rf $DIR_DOWNLOADS/FlameGraph $DIR_TOOLS
fi
if not_installed "plantuml.jar"; then
log "Installing PlantUML"
rm $DIR_DOWNLOADS/plantuml.jar
download https://github.com/plantuml/plantuml/releases/download/v1.2024.6/plantuml-mit-1.2024.6.jar plantuml.jar
cp $DIR_DOWNLOADS/plantuml.jar $DIR_TOOLS/plantuml.jar
fi
if not_installed "tsv-pretty"; then
log "Installing tsv-utils"
rm $DIR_DOWNLOADS/tsv-utils.tar.gz
rm -rf $DIR_DOWNLOADS/tsv-utils
download https://github.com/eBay/tsv-utils/releases/download/v2.2.0/tsv-utils-v2.2.0_linux-x86_64_ldc2.tar.gz tsv-utils.tar.gz
mkdir -p $DIR_DOWNLOADS/tsv-utils
tar -xzvf $DIR_DOWNLOADS/tsv-utils.tar.gz -C $DIR_DOWNLOADS/tsv-utils --strip-components=2
mv $DIR_DOWNLOADS/tsv-utils/* $DIR_TOOLS
rm -rf $DIR_DOWNLOADS/tsv-utils
fi
# ------------------------------------------------------------------------------
# Config editor
# ------------------------------------------------------------------------------
if is_linux; then
log "Configuring editor"
sudo update-alternatives --install /usr/bin/editor editor "$(brew_dir)/bin/hx" 100
fi
# ------------------------------------------------------------------------------
# Config GPG key
# ------------------------------------------------------------------------------
if [ ! -e ~/.gnupg/pubring.kbx ]; then
log "Configuring GPG key"
gpg --batch --gen-key <<EOF
Key-Type: 1
Key-Length: 4096
Subkey-Type: 1
Subkey-Length: 4096
Name-Real: Renato Dinhani
Name-Email: $EMAIL
Expire-Date: 0
%no-protection
EOF
fi
# ------------------------------------------------------------------------------
# Config SSH key
# ------------------------------------------------------------------------------
if [ ! -e ~/.ssh/dinhani.pub ]; then
log "Configuring SSH key"
ssh-keygen -t ed25519 -C "$EMAIL" -N "" -f ~/.ssh/dinhani
fi
# ------------------------------------------------------------------------------
# Config Git
# ------------------------------------------------------------------------------
log "Configuring Git"
git config --global user.email "$EMAIL"
git config --global user.name "Renato Dinhani"
# ------------------------------------------------------------------------------
# Install Desktop tools
# ------------------------------------------------------------------------------
if is_mac; then
# hardware
install_brew elgato-stream-deck
install_brew logitech-g-hub
# media
install_brew spotify
# terminal
install_brew iterm2
install_brew ghostty
# editors
install_brew insomnia
install_brew notable
install_brew visual-studio-code
install_brew rstudio
install_brew zed
# work / utils
install_brew google-chrome
install_brew slack
fi
# ------------------------------------------------------------------------------
# Install local compiled tools
# ------------------------------------------------------------------------------
# wsl2 source checkout
if is_linux && [ ! -d "$DIR_DOWNLOADS/WSL2-Linux-Kernel" ]; then
log "Cloning WSL2 source"
git clone https://github.com/microsoft/WSL2-Linux-Kernel $DIR_DOWNLOADS/WSL2-Linux-Kernel
fi
# perf
if is_linux && not_installed "perf"; then
log "Installing perf"
cd $DIR_DOWNLOADS/WSL2-Linux-Kernel/tools/perf
NO_LIBTRACEEVENT=1 make -j16
cp perf $DIR_TOOLS
cd
fi
# pikchr
if not_installed "pikchr"; then
log "Installing pikchr"
git clone https://github.com/drhsqlite/pikchr.git $DIR_DOWNLOADS/pikchr
cd $DIR_DOWNLOADS/pikchr
make
cp pikchr $DIR_TOOLS
cd
fi