-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·321 lines (265 loc) · 9.42 KB
/
init.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
#!/bin/bash
####
# config
# https://stackoverflow.com/a/5947802
info () {
local GREEN="\033[0;32m"
local NC="\033[0m"
echo -e "[${GREEN}info${NC}] $1"
}
warn () {
local YELLOW="\033[1;33m"
local NC="\033[0m"
echo -e "[${YELLOW}warning${NC}] $1"
}
# update apt package index
sudo apt update
sudo apt upgrade -y
# update git
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt update
sudo apt upgrade -y
# bunch of nice media codecs
apt install ubuntu-restricted-extras
# https://stackoverflow.com/questions/53930305/nodemon-error-system-limit-for-number-of-file-watchers-reached
FILE_WATCH_COUNT=$(find /proc/*/fd -user "$USER" -lname anon_inode:inotify -printf '%hinfo/%f\n' 2>/dev/null | xargs cat | grep -c '^inotify')
if (( $FILE_WATCH_COUNT < 80000 ));
then
info "increasing file watch count"
echo fs.inotify.max_user_watches=80000 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
fi
if ! command -v xclip &> /dev/null
then
info "installing xclip"
sudo apt install xclip
else
warn "skipping xclip install"
fi
if ! command -v neofetch &> /dev/null
then
info "installing neofetch"
sudo apt install neofetch
else
warn "skipping neofetch install"
fi
# get my email
info "please enter your email, this will be associated to your git config"
read MY_EMAIL
git config --global user.name "Giorgio Delgado"
git config --global user.email "$MY_EMAIL"
git config --global core.editor "nvim"
if [[ "$SHELL" == *zsh ]]
then
# user has zsh already as their default shell
info "User already has zsh set up as their main shell"
else
# first check to see if zsh is even available on their machine
if ! command -v zsh &> /dev/null
then
# user needs to install zsh
info "installing zsh"
sudo apt install zsh
info "completed installing zsh"
fi
fi
OH_MY_ZSH_DIR=~/.oh-my-zsh
if [[ ! -d "$OH_MY_ZSH_DIR" ]]
then
info "Installing ohmyzsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
warn "found .oh-my-zsh folder - skipping ohmyzsh install"
fi
info "symlinking custom .zshrc to ~"
# remove default .zshrc
rm ../.zshrc
# create symlink
ln -s ~/dotfiles/.zshrc ~/.zshrc
if ! command -v brew &> /dev/null
then
info "homebrew not installed, installing brew now"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# next steps to ensure `brew` is available in the PATH
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /home/giorgiodelgado/.profile
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/giorgiodelgado/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# Install Homebrew's dependencies if you have sudo access:
sudo apt install build-essential
else
warn "homebrew already installed, skipping install"
fi
if ! command -v node &> /dev/null
then
info "installing nvm (Node Version Manager)"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# source .zshrc so that `nvm` is recognized in the current session
source .zshrc
nvm install --lts
fi
if ! command -v prettierd &> /dev/null
then
info "installing prettier daemon"
npm install -g @fsouza/prettierd
fi
if ! command -v nvim &> /dev/null
then
info "neovim not installed, installing neovim now"
brew install neovim
info "symlinking nvim config to ~/.config/nvim"
ln -s ~/dotfiles/nvim ~/.config/nvim
info "installing packer to manage neovim plugins / deps"
git clone --depth 1 \
https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim
info "preparing to add custom NERDFont"
# mkdir -p ~/.local/share/fonts
git clone --filter=blob:none --sparse [email protected]:ryanoasis/nerd-fonts
cd nerd-fonts
git sparse-checkout add patched-fonts/JetBrainsMono
./install.sh JetBrainsMono
info "installed JetBrainsMono"
cd ..
else
warn "neovim already installed, skipping install"
fi
if ! command -v jq &> /dev/null
then
info "installing jq"
brew install jq
else
warn "jq already installed, skipping jq install"
fi
if ! command -v rg &> /dev/null
then
info "installing ripgrep"
brew install ripgrep
else
warn "rg binnary found - skipping ripgrep installation"
fi
if ! command -v gh &> /dev/null
then
info "installing github cli"
brew install gh
else
warn "gh binnary found - skipping github cli"
fi
if ! command -v fzf &> /dev/null
then
info "installing fzf "
brew install fzf
else
warn "fzf already installed, skipping jq install"
fi
if ! command -v fdfind &> /dev/null
then
info "installing fd (find alternative)"
sudo apt install fd-find
mkdir ~/.local/bin
ln -s $(which fdfind) ~/.local/bin/fd
else
warn "command 'fd' found, skipping fd installation"
fi
if ! command -v deno &> /dev/null
then
info "installing deno"
curl -fsSL https://deno.land/install.sh | sh
else
warn "command 'deno' found, skipping deno installation"
fi
if ! command -v diff-so-fancy &> /dev/null
then
info "installing diff-so-fancy"
brew install diff-so-fancy
info "updating git settings to use diff-so-fancy"
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --global interactive.diffFilter "diff-so-fancy --patch"
git config --global color.ui true
git config --global color.diff-highlight.oldNormal "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"
git config --global color.diff.meta "11"
git config --global color.diff.frag "magenta bold"
git config --global color.diff.func "146 bold"
git config --global color.diff.commit "yellow bold"
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global color.diff.whitespace "red reverse"
else
warn "diff-so-fancy already installed, skipping diff-so-fancy install"
fi
if ! command -v kitty &> /dev/null
then
info "kitty not installed, installing kitty now"
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
info "symlinking custom kitty.conf"
ln -s ~/dotfiles/kitty.conf ~/.config/kitty/kitty.conf
# PopOS-specific: Ensure that Kitty can be accessed via the launcher
# https://www.arm64.ca/post/creating-launch-plugins-for-pop-os-updated/
mkdir -p $HOME/.local/share/pop-launcher/scripts
printf '%s\n' \
'#!/bin/sh' \
'#' \
'# name: Kitty' \
"# icon: $HOME/.local/kitty.app/share/icons/hicolor/256x256/apps/kitty.png" \
'# description: Launch Kitty' \
'# keywords: kitty terminal' \
'' \
"$HOME/.local/kitty.app/bin/kitty" > $HOME/.local/share/pop-launcher/scripts/kitty.sh
chmod +x $HOME/.local/share/pop-launcher/scripts/kitty.sh
else
warn "kitty already installed, skipping install"
fi
# if ! command -v mysqlsh &> /dev/null
# then
# info "mysqlsh not installed, installing mysqlsh now"
#
# else
# fi
if ! command -v docker &> /dev/null
then
# https://docs.docker.com/engine/install/ubuntu
info "installing docker"
sudo apt install \
ca-certificates \
lsb-release
info "adding docker's GPG key"
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
info "setting up docker repository"
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
info "installing docker engine"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo curl -L "https://github.com/docker/compose/releases/download/v2.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# ensure that various docker commands have permission to run
# https://linuxhandbook.com/docker-permission-denied/
sudo groupadd docker &> /dev/null || echo "created docker group"
sudo usermod -aG docker $USER
else
info "docker already installed, skipping docker installation"
fi
if ! command -v gcloud &> /dev/null
then
info "beginning install of 'gcloud' cli"
# Gcloud CLI Stuff
# https://cloud.google.com/sdk/docs/install#deb
sudo apt install apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt update && sudo apt install google-cloud-cli
gcloud init
else
warn "'gcloud' already installed, skipping gcloud cli install"
fi
if ! command -v ~/cloud_sql_proxy &> /dev/null
then
info "beginning install of cloud sql proxy"
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O ~/cloud_sql_proxy
chmod +x ~/cloud_sql_proxy
else
warn "cloud sql proxy already installed at $HOME - skipping cloud sql proxy install"
fi