-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·205 lines (151 loc) · 8.87 KB
/
setup.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
#!/bin/bash
# Full Disk Access is necessary for writing to com.apple.universalaccess preference domain
# prompt code via https://stackoverflow.com/a/1885534
read -p "Make sure that the current terminal app ($TERM_PROGRAM) has full disk access (System Settings > Privacy & Security > Full Disk Access) before continuing. Type y to continue: " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# Disable Homebrew analytics
brew analytics off
# Turn off font smoothing
# See here for why https://tonsky.me/blog/monitors/
defaults write-currentHost -g AppleFontSmoothing -int 0
# Increase mouse speed
defaults write -g com.apple.mouse.scaling -float 7.960733
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Disable auto-capitalization
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
# Disable adding period after double space
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
# Disable smart quotes
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Enable dragging window from anywhere while holding Ctrl + Cmd
defaults write -g NSWindowShouldDragOnGesture -bool true
# Expand resize drag area
defaults write -g AppleEdgeResizeExteriorSize -int 15
# Don't display thumbnail after taking a screenshot
defaults write com.apple.screencapture show-thumbnail -bool false
# Use jpgs instead of pngs for screenshots since much more space-efficient
defaults write com.apple.screencapture type -string jpg
# Re-enable slow animations while holding down Shift
defaults write com.apple.dock slow-motion-allowed -bool true
# Always show proxy/document icons in window title bars
defaults write com.apple.universalaccess showWindowTitlebarIcons -bool true
# Remove rollover delay from title bar icon (even though should always appear from above command)
defaults write -g NSToolbarTitleViewRolloverDelay -float 0
# Always expand open/save dialogs
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Disable "Natural scrolling"
defaults write -g com.apple.swipescrolldirection -bool false
# Always show scroll bars
defaults write -g AppleShowScrollBars -string "Always"
# Jump to spot that's clicked when clicking on scroll bars
defaults write -g AppleScrollerPagingBehavior -int 1
# Set sidebar icon size to large
defaults write -g NSTableViewDefaultSizeMode -int 3
# Don't show open dialog when launching document apps
# via https://mas.to/@[email protected]/109851379681544342
defaults write -g NSShowAppCentricOpenPanelInsteadOfUntitledFile -bool false
# Disable chime when charging
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false
# Disable accent key when holding down keys
sudo defaults write -g ApplePressAndHoldEnabled -bool false
# "Delay until repeat" setting in System Settings > Keyboard
# 15 (225 ms) is normal minimum configurable via UI
# via https://gist.github.com/hofmannsven/ff21749b0e6afc50da458bebbd9989c5
# Also see https://github.com/ZaymonFC/mac-os-key-repeat
defaults write -g InitialKeyRepeat -int 15
# "Key repeat rate" setting in System Settings > Keyboard
# Note that this is the interval in between repeats, so the lower this value the faster the repeats will be fired
# 2 (30 ms) is normal minimum configurable via UI
# via https://gist.github.com/hofmannsven/ff21749b0e6afc50da458bebbd9989c5
# Also see https://github.com/ZaymonFC/mac-os-key-repeat
defaults write -g KeyRepeat -int 2
# Don't automatically rearrange Spaces
defaults write com.apple.dock mru-spaces -bool false
# Enable Dock autohide
defaults write com.apple.dock autohide -bool true
# Disable Dock delay
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -int 0
# Hide recent apps from Dock
defaults write com.apple.dock show-recents -bool false
# Hide all icons on Desktop
defaults write com.apple.finder CreateDesktop -bool false
# Always show full file extension in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Use List View as default view in Finder
defaults write com.apple.finder FXPreferredViewStyle -string Nlsv
# Show path bar in Finder
defaults write com.apple.finder ShowPathbar -bool true
# Don't display warning when changing file extension in Finder
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Set default location of new Finder windows to ~/Downloads
defaults write com.apple.finder NewWindowTarget -string "PfLo"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Downloads"
# Make crash reports appear as notifications
defaults write com.apple.CrashReporter UseUNC 1
# Show full URL in Safari address bar
# Update (6/25/23): doesn't seem to work as of Ventura 13.2 + Safari 16.3, can only change this via the Safari Settings window
# defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
# Set Safari home page to about:blank
defaults write com.apple.Safari HomePage -string "about:blank"
# Only enable AutoFill for address book (for icloud hide my email integration) and credit card (for apple card integration)
defaults write com.apple.Safari AutoFillFromAddressBook -bool true
defaults write com.apple.Safari AutoFillCreditCardData -bool true
defaults write com.apple.Safari AutoFillPasswords -bool false
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false
# Enable Develop menu in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
# Set TextEdit default document format to plain text
defaults write com.apple.TextEdit RichText -bool false
# Set Activity Monitor update frequency to 2s
defaults write com.apple.ActivityMonitor UpdatePeriod -int 2
# Xcode defaults configuration
defaults write com.apple.dt.Xcode CodeFoldingAnimationSpeed -float 0.0
defaults write com.apple.dt.Xcode XcodeCloudUpsellPromptEnabled -bool false
# Install app-specific keyboard shortcuts
# https://apple.stackexchange.com/questions/398561/how-to-set-system-keyboard-shortcuts-via-command-line
# Note that the -array-add command is not idempotent, and there's no built-in defaults -array-remove, so if this runs multiple times may have to do some manual cleanup by clearing the custommenu.apps array and re-adding everything from scratch
# Orion.app: Window > Move Tab > New Window is Opt+Shift+Cmd+M
# N.B. the full menu path is needed since just "New Window" conflicts with File > New Window
# For some reason though using full menu paths only works when adding to the "All Applications" app shortcuts, not to Orion
defaults write -g NSUserKeyEquivalents -dict-add "Window->Move Tab->New Window" "@~\$m"
# NetNewsWire.app: Edit > Copy Article URL is Shift+Cmd+C
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.ranchero.NetNewsWire-Evergreen"
defaults write com.ranchero.NetNewsWire-Evergreen NSUserKeyEquivalents -dict-add "Copy Article URL" -string "@\$C"
# Messages.app: Conversation > Delete Conversation is Opt+Cmd+9
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.apple.MobileSMS"
defaults write com.apple.MobileSMS NSUserKeyEquivalents -dict-add "Delete Conversation..." -string "@~9"
# Prime Video.app: View > Stay on top is Ctrl+Cmd+T
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.amazon.aiv.AIVApp"
defaults write com.amazon.aiv.AIVApp NSUserKeyEquivalents -dict-add "Stay on top" -string "@^t"
# IINA.app: Playback > Jump to Beginning is Shift+Cmd+J
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.colliderli.iina"
defaults write com.colliderli.iina NSUserKeyEquivalents -dict-add "Jump to Beginning" -string "@\$j"
# iTerm.app: Window > Move Session to Window is Opt+Shift+Cmd+M
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.googlecode.iterm2"
defaults write com.googlecode.iterm2 NSUserKeyEquivalents -dict-add "Move Session to Window" -string "@~\$m"
# BBEdit: Window > Notes is Opt+1
defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.barebones.bbedit"
defaults write com.barebones.bbedit NSUserKeyEquivalents -dict-add "Notes" -string "~1"
defaults write com.barebones.bbedit NSUserKeyEquivalents -dict-add "Remove Note" -string "@~9"
# Google Chrome: Tab > Pin Tab is Opt+Cmd+P
defaults write com.google.Chrome com.apple.custommenu.apps -array-add "com.google.Chrome"
defaults write com.google.Chrome NSUserKeyEquivalents -dict-add "Pin Tab" -string "~@p"
# iTerm2 defaults
defaults write com.googlecode.iterm2 QuitWhenAllWindowsClosed -bool true
# Manually download iTerm2 theme: https://github.com/fcaldera/github-primer-iterm2
sleep 2
# Install Rosetta 2
softwareupdate --install-rosetta --agree-to-license
sleep 2
# Restart processes
killall Dock
killall Finder
killall PowerChime
# TODO: automate and/or add message about logging out / rebooting