-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-apps.sh
executable file
·442 lines (394 loc) · 10.3 KB
/
install-apps.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
#!/usr/bin/env bash
set -e
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P )"
cd "$SCRIPTPATH"
# log
function log() {
color="\033[0;32m" # Green color
echo -e "$color[INFO]\\033[0m $@"
}
function warn() {
color="\033[1;33m" # Yellow color
echo -e "$color[WARN]\\033[0m $@"
}
# set LANG
set_lang() {
log "setting LANG"
apt-get -qq -y install locales
HAS_UTF8=$(locale -a | grep 'en_US.utf8' && echo true || echo false)
if [ "$HAS_UTF8" = false ]; then
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
fi
}
# install basic pkgs
install_basic_pkgs() {
log "installing basic pkgs"
pkgs=(
apt-utils
bat
binutils
cron
curl
exa
fd-find
fzf
gcc
git
iputils-ping
iredis
jq
lsb-release
lsof
make
mycli
net-tools
pandoc
ripgrep
silversearcher-ag
sudo
tar
telnet
tmux
tree
unzip
zip
)
apt-get -qq -y install ${pkgs[@]}
# for pkg in "${pkgs[@]}"; do
# log "* installing $pkg"
# apt-get -qq -y install "$pkg"
# done
}
# install sshd
function install_sshd() {
log "installing sshd"
apt-get -qq -y install openssh-server
mkdir -p /run/sshd
}
# install zsh
function install_zsh() {
log "installing zsh"
apt-get -qq -y install zsh
log "* set default shell to zsh"
chsh -s $(which zsh)
# install omz
log "* installing omz"
if [ ! -d "$HOME/.oh-my-zsh" ]; then
curl -sL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash
else
warn "* installing omz: skip"
fi
# install omz plugins
log "* installing omz plugins"
log " * installing zsh-autosuggestions"
if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]; then
git clone -q --depth 1 https://github.com/zsh-users/zsh-autosuggestions \
~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
else
warn " * installing zsh-autosuggestions: skip"
fi
log " * installing zsh-syntax-highlighting"
if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]; then
git clone -q --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git \
~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
else
warn " * installing zsh-syntax-highlighting: skip"
fi
}
# install go
function install_go() {
log "installing go"
log "* installing gvm"
if [ ! -d "$HOME/.gvm" ]; then
apt-get -qq -y install bison bsdmainutils
curl -sL https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer | bash
else
warn "* installing gvm: skip"
fi
log "* installing go by gvm"
source ~/.gvm/scripts/gvm && \
gvm install go1.18.10 -B && \
gvm use go1.18.10 && \
gvm install go1.21.0 && \
gvm use go1.21.0 --default
# install grpc
log "* installing grpc"
source ~/.gvm/scripts/gvm && \
go install google.golang.org/protobuf/cmd/[email protected] && \
go install google.golang.org/grpc/cmd/[email protected]
}
# install java
function install_java() {
log "installing java"
log "* installing jabba"
JABBA_VERSION=0.11.2 curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash
log "* installing java by jabba"
source ~/.jabba/jabba.sh && \
JAVA_VERSION=1.17.0 && \
jabba install openjdk@$JAVA_VERSION && \
jabba alias default openjdk@$JAVA_VERSION && \
jabba install [email protected]
}
# install node.js
function install_nodejs() {
log "installing node.js"
log "* installing nvm"
curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
log "* installing node.js by nvm"
source ~/.nvm/nvm.sh && \
nvm install --lts && \
nvm install-latest-npm
# install node packags
log "* installing node pkgs"
source ~/.nvm/nvm.sh && \
npm i -g nodemon
}
# install pyenv, python
function install_python() {
log "installing python"
log "* installing pyenv"
if [ ! -d "$HOME/.pyenv" ]; then
curl -sL https://pyenv.run | bash
else
warn "* installing pyenv: skip"
fi
log "* installing python by pyenv"
pkgs=(
build-essential
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
llvm
libncursesw5-dev
xz-utils
tk-dev
libxml2-dev
libxmlsec1-dev
libffi-dev
liblzma-dev
)
apt-get -qq -qq -y install "${pkgs[@]}"
export PATH="~/.pyenv/bin:$PATH" && \
eval "$(pyenv init -)" && \
pyenv install -s 3.11.1 && \
pyenv global 3.11.1
}
# install nvim
function install_nvim() {
log "installing nvim"
log "* installing dependences"
apt-get -qq -y install ninja-build gettext cmake unzip curl universal-ctags
log "* cloning nvim"
if [ ! -d "/tmp/neovim" ]; then
git clone -q https://github.com/neovim/neovim /tmp/neovim
else
warn "* cloning nvim: skip"
fi
log "* building"
cd /tmp/neovim && git checkout stable
make CMAKE_BUILD_TYPE=RelWithDebInfo
log "* installing"
make install
cd -
}
# install nvchad
function install_nvchad() {
log "installing nvchad"
if [ ! -d "$HOME/.config/nvim" ]; then
git clone --depth 1 https://github.com/NvChad/NvChad ~/.config/nvim
else
warn "installing nvchad: skip"
fi
}
# install nvim lazy plugins
function install_nvim_lazy_plugins() {
log "installing nvim lazy plugins"
go install github.com/jstemmer/gotags@master
}
# install nvim
function install_nvim_v1() {
log "installing nvim"
apt-get -qq -y install universal-ctags
curl -sLo- \
https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz | \
tar xzf - && \
cp nvim-linux64/bin/nvim /usr/bin/
log "* installing python pkg for nvim"
export PATH="~/.pyenv/bin:$PATH" && \
eval "$(pyenv init -)" && \
pip install autopep8 pylint pynvim
log "* installing node pkg for nvim"
source ~/.nvm/nvm.sh && \
npm i -g neovim
# install vim-plug and vim plugins
log "* installing vim-plug"
curl -sfLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
log "* installing vim plugs"
nvim +PlugInstall +qall
# install vim-go dependences
log "* installing vim-go dependences"
source ~/.gvm/scripts/gvm && \
go install github.com/klauspost/asmfmt/cmd/asmfmt@latest && \
go install github.com/go-delve/delve/cmd/dlv@latest && \
go install github.com/kisielk/errcheck@latest && \
go install github.com/davidrjenni/reftools/cmd/fillstruct@master && \
go install github.com/rogpeppe/godef@latest && \
go install golang.org/x/tools/cmd/goimports@master && \
go install github.com/mgechev/revive@latest && \
go install golang.org/x/tools/gopls@latest && \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && \
go install honnef.co/go/tools/cmd/staticcheck@latest && \
go install github.com/fatih/gomodifytags@latest && \
go install golang.org/x/tools/cmd/gorename@master && \
go install github.com/jstemmer/gotags@master && \
go install golang.org/x/tools/cmd/guru@master && \
go install github.com/josharian/impl@master && \
go install honnef.co/go/tools/cmd/keyify@master && \
go install github.com/fatih/motion@latest
# install coc extensions
log "* installing coc extensions"
source ~/.nvm/nvm.sh && \
EXT_PATH=~/.config/coc/extensions/ && \
mkdir -p $EXT_PATH && \
cd $EXT_PATH && \
npm i \
coc-css \
coc-docker \
coc-go \
coc-html \
coc-java \
coc-json \
coc-prettier \
coc-pyright \
coc-sh \
coc-sql \
coc-tsserver \
coc-qq -yaml
}
# install GitHub CLI
function install_github_cli() {
log "installing github cli"
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \
dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
| tee /etc/apt/sources.list.d/github-cli.list
apt-get -qq -y update && \
apt-get -qq -y install gh
}
# apt-get -qq -y update
# install_basic_pkgs
# set_lang
# install_sshd
# install_zsh
install_go
# install_nodejs
# install_python
# install_nvim
# install_nvchad
# install_github_cli
# exit now if running on linux
[ "$OSTYPE"=="linux-gnu"* ] && exit
# install homebrew
echo -n "installing homebrew: "
if command -v brew >> /dev/null; then
echo "skip"
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# source brew shell
[ -d /home/linuxbrew ] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
[ -f /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
# homebrew index
brew update -q
echo "OK"
fi
export HOMEBREW_NO_AUTO_UPDATE=1
function brew_install_casks () {
for i in "$@"; do
read -p "install $i? (Y/n)" confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || continue
echo -n "installing $i: "
brew install -q --cask "$i"
echo "OK"
done
}
function brew_install () {
for i in "$@"; do
echo -n "installing $i: "
brew install -q "$i"
echo "OK"
done
}
# install fonts
echo; echo "installing fonts..."
brew tap homebrew/cask-fonts
casks=(
font-jetbrains-mono-nerd-font
font-noto-nerd-font
)
brew_install_casks "${casks[@]}"
# install casks
# basic tools
echo; echo "installing system tools..."
casks=(
adrive
rectangle
shottr
karabiner-elements
monitorcontrol
the-unarchiver
keycastr
appcleaner
)
brew_install_casks "${casks[@]}"
# dev tools
echo; echo "installing dev tools..."
casks=(
iterm2
visual-studio-code
switchhosts
docker
insomnia
postman
)
brew_install_casks "${casks[@]}"
formulaes=(
watch
)
brew_install_casks "${formulaes[@]}"
echo; echo "installing more dev tools..."
casks=(
goland
pycharm
intellij-idea
mysqlworkbench
figma
charles
royal-tsx
)
brew_install_casks "${casks[@]}"
formulaes=(
pandoc
)
brew_install_casks "${formulaes[@]}"
# work apps
echo; echo "installing work apps..."
casks=(
google-chrome
safari-technology-preview
wechat
wechatwork
tencent-meeting
microsoft-office
)
brew_install_casks "${casks[@]}"
# entertainment apps
echo; echo "installing entertainment apps..."
casks=(
iina
qqmusic
qqlive
)
brew_install_casks "${casks[@]}"