-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·263 lines (231 loc) · 9.38 KB
/
setup
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
#!/usr/bin/env bash
# ###########################################################
# Setup system setting
# ###########################################################
### System
# Auto hide the menubar
defaults write -g _HIHideMenuBar -bool true
# Enable full keyboard access for all controls
defaults write -g AppleKeyboardUIMode -int 3
# Enable press-and-hold repeating
defaults write -g ApplePressAndHoldEnabled -bool false
defaults write -g InitialKeyRepeat -int 10
defaults write -g KeyRepeat -int 1
# Disable "Natural" scrolling
defaults write -g com.apple.swipescrolldirection -bool false
# Disable smart dash/period/quote substitutions
defaults write -g NSAutomaticDashSubstitutionEnabled -bool false
defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable automatic capitalization
defaults write -g NSAutomaticCapitalizationEnabled -bool false
# Using expanded "save panel" by default
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true
# Save to disk (not to iCloud) by default
defaults write -g NSDocumentSaveNewDocumentsToCloud -bool true
# Prefer tabs when opening documents
defaults write -g AppleWindowTabbingMode -string always
### Dock
# Set icon size and dock orientation
defaults write com.apple.dock tilesize -int 48
defaults write com.apple.dock orientation -string bottom
# Set dock to auto-hide
defaults write com.apple.dock autohide -bool true
# Disable to show recents, and light-dot of running apps
defaults write com.apple.dock show-recents -bool false
defaults write com.apple.dock show-process-indicators -bool false
### Finder
# Allow quitting via ⌘Q
defaults write com.apple.finder QuitMenuItem -bool true
# Disable warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Show all files and their extensions
defaults write com.apple.finder AppleShowAllExtensions -bool true
defaults write com.apple.finder AppleShowAllFiles -bool true
# Show path bar, and layout as multi-column
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder FXPreferredViewStyle -string clmv
# Search in current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string SCcf
# Keep the desktop clean
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false
# New window use the $HOME path
defaults write com.apple.finder NewWindowTarget -string PfHm
defaults write com.apple.finder NewWindowTargetPath -string "file://$HOME/"
# Allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool true
# Show metadata info, but not preview in info panel
defaults write com.apple.finder FXInfoPanesExpanded -dict MetaData -bool true Preview -bool false
### Trackpad
# Enable trackpad tap to click
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
### Others
# Disable quarantine for downloaded apps
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Avoid creating .DS_Store files on USB or network volumes
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Disable crash reporter
defaults write com.apple.CrashReporter DialogType -string none
# Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
# Disable personalized advertising
defaults write com.apple.AdLib forceLimitAdTracking -bool true
defaults write com.apple.AdLib allowApplePersonalizedAdvertising -bool false
defaults write com.apple.AdLib allowIdentifierForAdvertising -bool false
# Allow open applications from any source
sudo spctl --master-disable
dotfiles_dir="$HOME/.dotfiles"
home_config_dir="$HOME/.config"
echo "linking config file"
for folder_name in "$HOME/.dotfiles/config"/*; do
folder=$(basename "$folder_name")
target_folder="$home_config_dir/$folder"
if [ -d "$target_folder" ]; then
rm -rf "$target_folder"
echo "Removed existing $target_folder"
fi
ln -s "$folder_name" "$target_folder"
echo "Created symlink from $folder_name to $target_folder"
done
# ###########################################################
# Install non-brew various tools (PRE-BREW Installs)
# ###########################################################
if ! xcode-select --print-path &>/dev/null; then
echo "installing XCode Command Line Tools"
# Prompt user to install the XCode Command Line Tools
if ! xcode-select --install &>/dev/null; then
echo 'XCode Command Line Tools installed'
else
echo 'XCode Command Line Tools install failed!!!'
fi
else
echo "XCode Command Line Tools already installed"
fi
# ###########################################################
# install homebrew (CLI Packages)
# ###########################################################
HOMEBREW_PREFIX="/opt/homebrew"
if ! which brew; then
echo "installing homebrew"
if ! /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
echo "unable to install homebrew, script $0 abort!"
exit 2
fi
export PATH="$PATH:$HOMEBREW_PREFIX/bin"
else
echo "homebrew already installed"
fi
case "${SHELL}" in
*/bash*)
shell_rcfile="${HOME}/.bash_profile"
;;
*/zsh*)
shell_rcfile="${ZDOTDIR:-"${HOME}"}/.zshrc"
;;
*/fish*)
shell_rcfile="${HOME}/.config/fish/config.fish"
;;
*)
shell_rcfile="${ENV:-"${HOME}/.profile"}"
;;
esac
if grep -qs "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\"" "${shell_rcfile}"; then
if ! [[ -x "$(command -v brew)" ]]; then
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
fi
else
(
echo
echo "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\""
) >>"${shell_rcfile}"
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
fi
###########################################################
# Config
###########################################################
for file in "$HOME/.dotfiles/link"/*; do
filename=$(basename "$file")
target_file="$HOME/$filename"
if [ -f "$target_file" ]; then
rm -f "$target_file"
echo "Removed existing $target_file"
fi
if [ -f "$file" ]; then
ln -s "$file" "$HOME/$filename"
echo "Created symlink from $file to $target_file"
fi
done
# Install Homebrew packages
brew bundle install --file "$dotfiles_dir"/Brewfile
# Install fish plugins
fish -c "fisher update"
fish -c "tide configure --auto --style=Lean --prompt_colors='True color' --show_time=No --lean_prompt_height='Two lines' --prompt_connection=Disconnected --prompt_spacing=Compact --icons='Few icons' --transient=No"
# Set fish as default shell
fish_bin=$(which fish)
if ! grep -qs "${fish_bin}" "/etc/shells"; then
echo "$fish_bin" | sudo tee -a /etc/shells
fi
chsh -s "$(which fish)"
# Config git
git config --global core.editor "nvim"
git config --global core.pager "delta"
git config --global core.excludesFile "$HOME"/.gitignore_global
git config --global core.attributesFile "$HOME"/.gitattributes_global
git config --global init.defaultbranch "main"
git config --global interactive.difffilter "delta --color-only"
git config --global push.autoSetupRemote true
git config --global merge.conflictstyle diff3
git config --global fetch.writeCommitGraph true
git config --global rerere.enabled true
git config --global column.ui auto # arrange _branch name_ (`git branch`) with multi-column, defautl is pager
git config --global branch.sort -committerdate # sort by last commit date descending
git config --global gpg.format ssh # ssh format gpg signingKey
git config --global user.signingKey ~/.ssh/key.pub # gpg signingKey file
git config --global commit.gpgsign true # commit with gigsign
git config --global maintenance.auto false # start maintenance cronJobs
git config --global maintenance.strategy incremental # gc: disabled, commit-graph: hourly, prefetch: hourly, loose-objects: daily, incremental-repack: daily
git config --global diff.colormoved default
git config --global diff.tool difftastic
git config --global diff.external difft
git config --global difftool.prompt false
git config --global difftool.difftastic.cmd "difft $LOCAL $REMOTE"
git config --global pager.difftool true
git config --global delta.light false
git config --global delta.navigate true
git config --global delta.side-by-side true
git config --global delta.line-numbers true
git config --global delta.syntax-theme Dracula
# My neovim config
echo "Download neovim config"
git clone https://github.com/BBBoy01/nvim ~/.config/nvim
# Tmux tpm plugin manager
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Neovim plugin test framework
luarocks --lua-version=5.1 install vusted
# Init rust
rustup-init
rustup default stable
# refresh cache
fc-cache -f -v
# Install lts node
pnpm env use -g lts
# pnpm relate
pnpm i -g \
"vite" \
"@angular/cli"
# Init yabai
sudo yabai --load-sa
yabai --start-service
skhd --start-service
brew cleanup
brew doctor
echo "All done"
echo "Sign out & Sign in for update config"