-
Notifications
You must be signed in to change notification settings - Fork 0
/
osx_bootstrap.sh
286 lines (243 loc) · 6.11 KB
/
osx_bootstrap.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
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Original: https://gist.github.com/mrichman/f5c0c6f0c0873392c719265dfd209e12
# helpers
function echo_ok() { echo -e '\033[1;32m'"$1"'\033[0m'; }
function echo_warn() { echo -e '\033[1;33m'"$1"'\033[0m'; }
function echo_error() { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; }
echo_ok "Install starting. You may be asked for your password (for sudo)."
# requires xcode and tools!
xcode-select -p || exit "XCode must be installed from the AppStore!"
# homebrew
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
if hash brew &>/dev/null; then
echo_ok "Homebrew already installed. Getting updates..."
brew update
brew doctor
else
echo_warn "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Update homebrew recipes
brew update
# Install GNU core utilities (those that come with OS X are outdated)
# brew install coreutils
# brew install gnu-sed --with-default-names
# brew install gnu-tar --with-default-names
# brew install gnu-indent --with-default-names
# brew install gnu-which --with-default-names
# brew install gnu-grep --with-default-names
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
# brew install findutils
# Install Bash
brew install bash
PACKAGES=(
asdf
ansible
awscli
bat
bash-completion
bash-git-prompt
coreutils
cookiecutter
curl
cowsay
cmake
copier
direnv
eg-examples
fish
fd
ffmpeg
fzf
git
git-extras
gh
glow
btop
htop
ripgrep
jq
kubectl
keyring
lazygit
lua
luarocks
nomad
neovim
starship
pipenv
python3
pyenv
pre-commit
protobuf
protoc-gen-go
protoc-gen-go-grpc
terraform
thefuck
tree
terminal-notifier
tldr
tmux
virtualenv
watch
wget
youtube-dl
yarn
# zsh
# zsh-autosuggestions
# zsh-completions
# zsh-syntax-highlighting
)
echo_ok "Installing packages..."
brew install "${PACKAGES[@]}"
echo_ok "Cleaning up..."
brew cleanup
echo_ok "Installing cask..."
# brew install caskroom/cask/brew-cask
brew tap caskroom/cask
CASKS=(
1password
alacritty
adobe-creative-cloud
discord
orbstack
google-chrome
google-drive
google-cloud-sdk
notion
telegram
tailscale
skype
slack
spotify
intellij-idea
visual-studio-code
vlc
zoom
)
echo_ok "Installing cask apps..."
brew install --cask "${CASKS[@]}"
echo_ok "Installing fonts..."
brew tap homebrew/cask-fonts
FONTS=(
font-fira-code-nerd-font
font-jetbrains-mono-nerd-font
)
brew cask install "${FONTS[@]}"
echo_ok "Installing asdf plugins..."
ASDF_PLUGINS=(
python
go
ruby
rust
)
for i in "${ASDF_PLUGINS[@]}"; do
asdf plugin add "$i"
done
echo_ok "Installing and settin global ruby, golang, python and rust..."
asdf install ruby 3.0.6
asdf install golang 1.20.14
asdf install python 3.10.12
asdf install rust 1.74.1
asdf global ruby 3.0.6
asdf global golang 1.20.14
asdf global python 3.10.12
asdf global rust 1.74.1
echo_ok "Installing fish shell plugin manager..."
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
echo_ok "Installing development environtment neovim, alacritty, fish, tmux..."
# git clone -b thin-packer-config https://github.com/rshkarin/.dotfiles.git "$HOME/.dotfiles"
config_dir="$HOME/.config"
if [ ! -d "$config_dir" ]; then
echo_ok "Creating ~/.config directory..."
mkdir -p "$config_dir"
fi
# Function to create symlink and backup existing folder if necessary
create_symlink() {
local target="$1"
local link_name="$2"
if [ -e "$link_name" ]; then
echo_warn "Backup existing $link_name to $link_name.bkp"
mv "$link_name" "$link_name.bkp"
fi
echo_ok "Creating symlink $link_name -> $target"
ln -s "$target" "$link_name"
}
# Create symlinks for nvim, alacritty, and fish
create_symlink "$HOME/.dotfiles/nvim" "$config_dir/nvim"
create_symlink "$HOME/.dotfiles/alacritty" "$config_dir/alacritty"
create_symlink "$HOME/.dotfiles/fish" "$config_dir/fish"
create_symlink "$HOME/.dotfiles/scripts" "$config_dir/scripts"
create_symlink "$HOME/.dotfiles/starship.toml" "$config_dir/starship.toml"
create_symlink "$HOME/.dotfiles/tmux.conf" "$HOME/tmux.conf"
create_symlink "$HOME/.dotfiles/.ideavimrc" "$HOME/.ideavimrc"
echo_ok "Configuring python keyring..."
cat << EOF > "$HOME/.config/python_keyring/keyringrc.cfg"
[backend]
default-keyring=keyring.backends.macOS.Keyring
EOF
echo_ok "Installing fish shell plugins..."
FISH_PLUGINS=(
jorgebucaran/fisher
PatrickF1/fzf.fish
jomik/fish-gruvbox
h-matsuo/fish-color-scheme-switcher
danhper/fish-ssh-agent
meaningful-ooo/sponge
franciscolourenco/done
rstacruz/fish-asdf
)
fisher install "${FISH_PLUGINS[@]}"
echo_ok "Configuring git..."
echo '## Please enter your full name:'
read -r git_fullname
echo '## Please enter your git email address: '
read -r git_email
cat << EOF > "$HOME/.gitconfig"
[user]
name = $git_fullname
email = $git_email
signingKey = $(op read "op://Private/SSH Key Machine/public key") $git_email
[url "[email protected]:"]
insteadOf = https://github.com/
[alias]
co = checkout
br = branch
[pull]
rebase = true
[push]
default = current
[gpg]
format = ssh
[commit]
gpgsign = true
[tag]
gpgsign = true
[gpg "ssh"]
allowedSignersFile = ~/.config/git/allowed_signers
[init]
defaultBranch = master
EOF
echo "Git configuration file created at ~/.gitconfig"
echo_ok "Configuring SSH..."
cat << EOF > "$HOME/.ssh/config"
Include ~/.orbstack/ssh/config
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
EOF
cat << EOF > "$HOME/.ssh/id_rsa.pub"
$(op read "op://Private/SSH Key Machine/public key") $git_email
EOF
op read "op://Private/SSH Key Machine/private key?ssh-format=openssh" > "$HOME/.ssh/id_rsa"
echo_ok 'Running OSX Software Updates...'
sudo softwareupdate -i -a
echo_ok "Creating folder structure..."
[[ ! -d ~/Work ]] && mkdir ~/Work
echo_ok "Bootstrapping complete"