-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure_macos.sh
280 lines (269 loc) · 12.3 KB
/
configure_macos.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
if ! [ -e ~/.ssh/id_rsa.pub ]; then
ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa" -N ""
fi
if ! [ -e ~/.ssh/known_hosts ]; then
# Allows git clone without fingerprint confirmation
ssh-keyscan github.com >> ~/.ssh/known_hosts
fi
# For Apple Silicon
softwareupdate --install-rosetta --agree-to-license
# XCode command-line tools
xcode-select --install
echo "Wait for the xcode-select GUI installer and press enter"
read -s
if [ -e /opt/homebrew/bin/brew ]; then
echo "Homebrew already installed"
else
# This will require sudo access and waits for confirmation
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Add homebrew to path for the rest of the script
eval "$(/opt/homebrew/bin/brew shellenv)"
# Group settings that require sudo together
# Disable spotlight for better battery and SSD life:
sudo mdutil -a -i off
# Tends to hang with 100% cpu load
launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist 2>/dev/null
# Time zone from "sudo systemsetup -listtimezones"
#! This crashes AFTER setting time zone, this is normal
sudo systemsetup -settimezone "Europe/Amsterdam" 2>/dev/null
# Wake on lid open
sudo pmset -a lidwake 1
# Restart on freeze
sudo systemsetup -setrestartfreeze on
# No sleep if not explicitly instructed to do so
sudo pmset -a displaysleep 0
sudo pmset -a sleep 0
# Don't send search queries to Apple
sudo defaults write com.apple.Safari UniversalSearchEnabled false
sudo defaults write com.apple.Safari SuppressSearchSuggestions true
# Show full URL in Safari address bar
sudo defaults write com.apple.Safari ShowFullURLInSmartSearchField true
# Safari home page
sudo defaults write com.apple.Safari HomePage -string "about:blank"
# Do not open files after downloading in Safari
sudo defaults write com.apple.Safari AutoOpenSafeDownloads false
# Hide Safari bookmarks bar
sudo defaults write com.apple.Safari ShowFavoritesBar false
# Enable Safari debug and develop menus.
sudo defaults write com.apple.Safari IncludeInternalDebugMenu true
sudo defaults write com.apple.Safari IncludeDevelopMenu true
# Safari search on page with "contains"
sudo defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly false
# Disable Safari auto correct
sudo defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled false
# Disable Safari auto fill
sudo defaults write com.apple.Safari AutoFillFromAddressBook false
sudo defaults write com.apple.Safari AutoFillPasswords false
sudo defaults write com.apple.Safari AutoFillCreditCardData false
sudo defaults write com.apple.Safari AutoFillMiscellaneousForms false
# Block pop-ups in Safari
sudo defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically false
sudo defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically false
brew update --verbose
# For Python 3.10.0 on Apple Silicon
brew install readline openssl
# For Ruby 3.2
brew install libyaml
# For keepassxc-cli
brew install --build-from-source libgpg-error
# Install into applications, not as a cli
brew install --cask mpv docker tailscale
brew install mas keepassxc karabiner-elements hammerspoon visual-studio-code font-jetbrains-mono-nerd-font google-chrome qbittorrent obs iterm2 gimp brave-browser the_silver_searcher michaeldfallen/formula/git-radar lsd eza bat diff-so-fancy uv notunes chatgpt slack whatsapp discord lunar double-commander elgato-control-center rode-central mimestream vlc zoom notion notion-calendar
# Need to check for network issues
# brew install orbstack
if [ -e ~/dotfiles ]; then
echo "Dotfiles already cloned"
else
git clone https://github.com/grigoryvp/dotfiles.git ~/dotfiles
while true; do
keepassxc-cli show -s ~/dotfiles/auth/passwords.kdbx github
if [ $? -eq 0 ]; then
break
fi
done
cat ~/.ssh/id_rsa.pub
echo "Add ssh to GitHub and press enter"
read -s
rm -rf ~/dotfiles
git clone [email protected]:grigoryvp/dotfiles.git ~/dotfiles
fi
if [ -e ~/xi ]; then
echo "Knowledge base already cloned"
else
git clone [email protected]:grigoryvp/xi.git ~/.xi
fi
printf '#!/bin/sh\n. ~/dotfiles/shell-cfg.sh\n' > ~/.bashrc
printf '#!/bin/sh\n. ~/dotfiles/shell-cfg.sh\n' > ~/.zshrc
printf '#!/bin/sh\n. ~/.bashrc\n' > ~/.bash_profile
printf '[include]\npath = ~/dotfiles/git-cfg.toml\n' > ~/.gitconfig
if ! [ -e ~/.hammerspoon ]; then
mkdir ~/.hammerspoon
fi
ln -fs ~/dotfiles/hammerspoon/init.lua ~/.hammerspoon/init.lua
ln -fs ~/dotfiles/.screenrc ~/.screenrc
ln -fs ~/dotfiles/.gitattributes ~/.gitattributes
ln -fs ~/dotfiles/.rubocop.yml ~/.rubocop.yml
if ! [ -e ~/.config/lsd ]; then
mkdir -p ~/.config/lsd
fi
ln -fs ~/dotfiles/lsd.config.yaml ~/.config/lsd/config.yaml
if ! [ -e ~/.config/powershell ]; then
mkdir -p ~/.config/powershell
fi
ln -fs ~/dotfiles/profile.ps1 ~/.config/powershell/profile.ps1
code --install-extension grigoryvp.language-xi
code --install-extension grigoryvp.memory-theme
code --install-extension grigoryvp.goto-link-provider
code --install-extension grigoryvp.markdown-inline-fence
code --install-extension grigoryvp.markdown-python-repl-syntax
code --install-extension grigoryvp.markdown-pandoc-rawattr
code --install-extension vscodevim.vim
code --install-extension EditorConfig.EditorConfig
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension esbenp.prettier-vscode
code --install-extension formulahendry.auto-close-tag
code --install-extension dnut.rewrap-revived
code --install-extension streetsidesoftware.code-spell-checker
code --install-extension streetsidesoftware.code-spell-checker-russian
code --install-extension mark-wiemer.vscode-autohotkey-plus-plus
VSCODE_DIR=~/Library/Application\ Support/Code/User
mkdir -p $VSCODE_DIR
ln -fs ~/dotfiles/vscode_keybindings.json $VSCODE_DIR/keybindings.json
ln -fs ~/dotfiles/vscode_settings.json $VSCODE_DIR/settings.json
ln -fs ~/dotfiles/vscode_tasks.json $VSCODE_DIR/tasks.json
ln -fs ~/dotfiles/vscode_snippets $VSCODE_DIR/snippets
mkdir -p ~/.config/mpv
echo "save-position-on-quit" > ~/.config/mpv/mpv.conf
echo "loop-file=inf" >> ~/.config/mpv/mpv.conf
open /Applications/Karabiner-Elements.app
echo "Add Karabiner to accessability and press enter"
read -s
# Entire config dir should be symlinked
rm -rf ~/.config/karabiner
ln -fs ~/dotfiles/karabiner ~/.config/karabiner
echo "Installing uvc-util..."
CUR_DIR=$(pwd)
git clone https://github.com/jtfrey/uvc-util.git
cd uvc-util/src
gcc -o uvc-util -framework IOKit -framework Foundation uvc-util.m UVCController.m UVCType.m UVCValue.m
chmod +x uvc-util
mkdir -p ~/.local/bin/
cp uvc-util ~/.local/bin/
cd $CUR_DIR
rm -rf uvc-util
# Download and install HEY.com mail app
echo "Downloading HEY.com client..."
curl -LOSs "https://hey-desktop.s3.amazonaws.com/HEY-arm64.dmg"
hdiutil attach "./HEY-arm64.dmg" 1>/dev/null
vol_name=$(ls /Volumes | grep -E "^HEY.+arm64$")
echo "Installing ${vol_name} ..."
cp -R "/Volumes/${vol_name}/HEY.app" /Applications/
hdiutil detach "/Volumes/${vol_name}" 1>/dev/null
rm "./HEY-arm64.dmg"
# Input method name lookup for debug purpose
curl -Ls https://raw.githubusercontent.com/daipeihust/im-select/master/install_mac.sh | sh
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
git clone https://github.com/rkh/rbenv-update ~/.rbenv/plugins/rbenv-update
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
git clone https://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build
git clone https://github.com/nodenv/nodenv-update.git ~/.nodenv/plugins/nodenv-update
git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
# Seems not working on macOS, maybe switch to phpvm?
git clone https://github.com/phpenv/phpenv.git ~/.phpenv
git clone https://github.com/php-build/php-build ~/.phpenv/plugins/php-build
git clone https://github.com/jridgewell/phpenv-update ~/.phpenv/plugins/phpenv-update
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.nodenv/bin:$PATH"
export PATH="$HOME/.swiftenv/bin:$PATH"
export PATH="$HOME/.phpenv/bin:$PATH"
uv python install 3.13
rbenv install 3.4.1
rbenv global 3.4.1
nodenv install 23.7.0
nodenv global 23.7.0
# Close any preferences so settings are not overwritten.
osascript -e 'tell application "System Preferences" to quit'
# Show hidden files, folders and extensions.
chflags nohidden ~/Library
defaults write com.apple.finder AppleShowAllFiles YES
defaults write -g AppleShowAllExtensions true
# Keep folders on top while sorting by name in Finder.
defaults write com.apple.finder _FXSortFoldersFirst true
# Change extension without a warning.
defaults write com.apple.finder FXEnableExtensionChangeWarning false
# Do not create .DS_Store on removable media and network.
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
defaults write com.apple.desktopservices DSDontWriteUSBStores true
# Do not verify disk images
defaults write com.apple.frameworks.diskimages skip-verify true
defaults write com.apple.frameworks.diskimages skip-verify-locked true
defaults write com.apple.frameworks.diskimages skip-verify-remote true
# Show Finder path and status bars.
defaults write com.apple.finder ShowPathbar true
defaults write com.apple.finder ShowStatusBar true
# List view for all Finder windows by default
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Disable empty trash warning
defaults write com.apple.finder WarnOnEmptyTrash false
# Enable keyboard repeat, need to restart after that.
defaults write -g ApplePressAndHoldEnabled false
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# Prevent OS from changing text being entered.
defaults write -g NSAutomaticCapitalizationEnabled false
defaults write -g NSAutomaticDashSubstitutionEnabled false
defaults write -g NSAutomaticPeriodSubstitutionEnabled false
defaults write -g NSAutomaticQuoteSubstitutionEnabled false
defaults write -g NSAutomaticSpellingCorrectionEnabled false
# Max touchpad speed that can be set via GUI, cli can go beyound than.
defaults write -g com.apple.trackpad.scaling 3
# Switch off typing disable while trackpad is in use.
defaults write com.apple.applemultitouchtrackpad TrackpadHandResting -int 0
# Save to disk instead of iCloud by default.
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud false
# Disable the app open confirmation.
defaults write com.apple.LaunchServices LSQuarantine false
# Input langauges and locale
defaults write -g AppleLanguages -array "en" "ru" "ja"
defaults write -g AppleLocale -string "en_RU"
# Instant dock auto hiding
defaults write com.apple.dock autohide true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
# No recent apps in dock
defaults write com.apple.dock show-recents false
# Require password
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Copy email without name in Mail
defaults write com.apple.mail AddressesIncludeNameOnPasteboard false
# Disable inline attachments in Mail
defaults write com.apple.mail DisableInlineAttachmentViewing true
# "Continuos scroll" by default for PDF preview
defaults write com.apple.Preview kPVPDFDefaultPageViewModeOption 0
# Don't auto-show dock on mouse hover (m1-slash instead)
defaults write com.apple.dock autohide-delay -float 999999
# Change slow "Genie" dock minimize animation to fast "Scale"
defaults write com.apple.dock "mineffect" -string "scale" && killall Dock
# Disable "animate opening applications"
defaults write com.apple.dock launchanim -bool false
# Disable "show suggested and recent applications in Dock"
defaults write com.apple.dock show-recents -bool false
# Disable Mission Control "hot corners" (they trigger accidently a lot)
defaults write com.apple.dock wvous-tl-corner -int 0
defaults write com.apple.dock wvous-tr-corner -int 0
defaults write com.apple.dock wvous-bl-corner -int 0
defaults write com.apple.dock wvous-br-corner -int 0
# Auto-hide dock to get more vertical space (everything is on hotkeys)
defaults write com.apple.dock autohide -bool true
# Mute alerts
osascript -e "set volume alert volume 0"
# Mute volume change feedback
defaults write -g "com.apple.sound.beep.feedback" -bool false
# Disable screen saver (manually turn off screen by locking the laptop)
defaults -currentHost write com.apple.screensaver idleTime -int 0
# Apply changes
killall Dock
killall SystemUIServer