-
Notifications
You must be signed in to change notification settings - Fork 2
/
mac-setup.sh
executable file
·507 lines (378 loc) · 19.2 KB
/
mac-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
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
#!/usr/bin/env bash
# go through https://registerspill.thorstenball.com/p/new-year-new-job-new-machine and update this script
# Ask for the administrator password upfront
sudo -v
###############################################################################
# Finder #
###############################################################################
# Icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false
# Visibility of hidden files
defaults write com.apple.finder AppleShowAllFiles -bool true
# New window target
# Computer : `PfCm`
# Volume : `PfVo`
# $HOME : `PfHm`
# Desktop : `PfDe`
# Documents : `PfDo`
# All My Files : `PfAF`
# Other… : `PfLo`
defaults write com.apple.finder NewWindowTarget -string 'PfHm'
#defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"
# Show Path Bar.
defaults write com.apple.finder ShowPathbar -bool true
# Show Status Bar.
defaults write com.apple.finder ShowStatusBar -bool true
# Preferred view style
# Icon View : `icnv`
# List View : `Nlsv`
# Column View : `clmv`
# Cover Flow : `Flwv`
# After configuring preferred view style, clear all `.DS_Store` files
# to ensure settings are applied for every directory
# sudo find / -name ".DS_Store" --delete
defaults write com.apple.finder FXPreferredViewStyle -string 'Nlsv'
# Arrange by
# Kind, Name, Application, Date Last Opened,
# Date Added, Date Modified, Date Created, Size, Tags, None
defaults write com.apple.finder FXPreferredGroupBy -string "Date Modified"
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# don't write DS_Store files on usb
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
killall Finder
###############################################################################
# Dock
###############################################################################
# Icon size of Dock items
defaults write com.apple.dock tilesize -int 42
# Lock the Dock size
defaults write com.apple.dock size-immutable -bool true
# Dock magnification
defaults write com.apple.dock magnification -bool false
# Minimization effect: 'genie', 'scale', 'suck'
defaults write com.apple.dock mineffect -string 'scale'
# Prefer tabs when opening documents: 'always', 'fullscreen', 'manual'
defaults write NSGlobalDomain AppleWindowTabbingMode -string 'always'
# Dock orientation: 'left', 'bottom', 'right'
defaults write com.apple.dock 'orientation' -string 'right'
# Dock pinning: 'start', 'middle', 'end'
# defaults write com.apple.dock pinning -string 'middle'
# Double-click a window's title bar to:
# None
# Mimimize
# Maximize (zoom)
defaults write NSGlobalDomain AppleActionOnDoubleClick -string "Maximize"
# Minimize to application
defaults write com.apple.dock minimize-to-application -bool true
# Animate opening applications
defaults write com.apple.dock launchanim -bool false
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Auto-hide delay
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0.5
# Show indicators for open applications
defaults write com.apple.dock show-process-indicators -bool true
# Show recent applications in Dock
defaults write com.apple.dock show-recents -bool false
killall Dock
## other
# disable auto correct
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
# Disables auto capitalization
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
# Disables "smart" dashes
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Disables automatic period substitutions
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
# Disables smart quotes
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
###############################################################################
# Keyboard
###############################################################################
# enable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true
# Set key repeat rate (minimum 1)
# Off: 300000
# Slow: 120
# Fast: 2
# default 6
defaults write NSGlobalDomain KeyRepeat -int 6
# Set delay until repeat (in milliseconds)
# Long: 120
# Short: 15
# default 25
defaults write NSGlobalDomain InitialKeyRepeat -int 25
# Full Keyboard Access
# In windows and dialogs, press Tab to move keyboard focus between:
# 1 : Text boxes and lists only
# 3 : All controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Use F1, F2, etc. keys as standard function keys
defaults write NSGlobalDomain com.apple.keyboard.fnState -bool true
# Set Double and Single quotes
defaults write NSGlobalDomain NSUserQuotesArray -array '"\""' '"\""' '"'\''"' '"'\''"'
# Prevent accidental Power button presses from sleeping system
defaults write com.apple.loginwindow PowerButtonSleepsSystem -bool no
###############################################################################
# Notifications
###############################################################################
# Notification banner on screen time
# Default 5 seconds
defaults write com.apple.notificationcenterui bannerTime 2
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
# Trackpad: enable tap to click for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# disable natural scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
###############################################################################
# Sharing
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
sudo scutil --set ComputerName "lars-mbp-14"
sudo scutil --set HostName "lars-mbp-14"
sudo scutil --set LocalHostName "lars-mbp-14"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server \
NetBIOSName -string "lars-mbp-14"
###############################################################################
# Security & Privacy
###############################################################################
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -bool true
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Allow applications downloaded from anywhere
#sudo spctl --master-disable
# Turn on Firewall
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1
# Allow signed apps
sudo defaults write /Library/Preferences/com.apple.alf allowsignedenabled -bool true
# Firewall logging
sudo defaults write /Library/Preferences/com.apple.alf loggingenabled -bool false
# Stealth mode
sudo defaults write /Library/Preferences/com.apple.alf stealthenabled -bool true
###############################################################################
# Network
###############################################################################
# Use Google public DNS (IP Addresses, space delimited)
#sudo networksetup -setdnsservers "$connected_service" 8.8.8.8 8.8.4.4
###############################################################################
# Mission Control
###############################################################################
# Mission Control animation duration
defaults write com.apple.dock expose-animation-duration -float 0.1
# Automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# When switching to an application, switch to a Space with open windows for the application
defaults write NSGlobalDomain AppleSpacesSwitchOnActivate -bool true
# Group windows by application in Mission Control
# (i.e. use the old Exposé behavior instead)
defaults write com.apple.dock expose-group-by-app -bool false
# Displays have seperate Spaces
defaults write com.apple.spaces spans-displays -bool false
# Reset Launchpad
find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete
# Add iOS Simulator to Launchpad
#if [ -e "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" ]; then
# sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" \
# "/Applications/Simulator.app"
#fi
# Hot corners
# 0 : NOP
# 2 : Mission Control
# 3 : Show application windows
# 4 : Desktop
# 5 : Start screen saver
# 6 : Disable screen saver
# 7 : Dashboard
# 10 : Put display to sleep
# 11 : Launchpad
# 12 : Notification Center
# Top left screen corner
defaults write com.apple.dock wvous-tl-corner -int 0
defaults write com.apple.dock wvous-tl-modifier -int 0
# Top right screen corner
defaults write com.apple.dock wvous-tr-corner -int 0
defaults write com.apple.dock wvous-tr-modifier -int 0
# Bottom left screen corner
defaults write com.apple.dock wvous-bl-corner -int 0
defaults write com.apple.dock wvous-bl-modifier -int 0
# Bottom right screen corner
defaults write com.apple.dock wvous-br-corner -int 0
defaults write com.apple.dock wvous-br-modifier -int 0
###############################################################################
# Users & Groups
###############################################################################
# Display login window as: Name and password
sudo defaults write /Library/Preferences/com.apple.loginwindow "SHOWFULLNAME" -bool true
# Automatic login as current user or "Guest" for guest login
#sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser -string `whoami`
# Allow guests to login to this computer
sudo defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool false
###############################################################################
# Screen #
###############################################################################
# Save screen captures in `Pictures` instead of `Desktop`.
defaults write com.apple.screencapture location ~/Pictures
killall SystemUIServer
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
###############################################################################
# iTunes
###############################################################################
# Don't automatically sync connected devices
defaults write com.apple.itunes dontAutomaticallySyncIPods -bool true
###############################################################################
# App Store
###############################################################################
# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Automatically check for updates
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
# Download newly available updates in the background
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool true
# Install app updates
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdate -bool true
# Install macOS updates
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdateRestartRequired -bool false
# Install system data files and security updates
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate ConfigDataInstall -bool true
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CriticalUpdateInstall -bool true
###############################################################################
# Bluetooth
###############################################################################
# Improve sound quality for Bluetooth headphones/headsets
#defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
#defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 48
#defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 40
#defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 48
#defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Max" 53
#defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Min" 48
#defaults write com.apple.BluetoothAudioAgent "Stream - Flush Ring on Packet Drop (editable)" 30
#defaults write com.apple.BluetoothAudioAgent "Stream - Max Outstanding Packets (editable)" 15
#defaults write com.apple.BluetoothAudioAgent "Stream Resume Delay" "0.75"
###############################################################################
# Displays
###############################################################################
# Automatically adjust brightness
defaults write com.apple.BezelServices dAuto -bool true
sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool true
# Subpixel font rendering on non-Apple LCDs
# 0 : Disabled
# 1 : Minimal
# 2 : Medium
# 3 : Smoother
# 4 : Strong
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Enable HiDPI display modes (requires restart)
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
# Show mirroring options in the menu bar when available
defaults write com.apple.airplay showInMenuBarIfPresent -bool true
###############################################################################
# Desktop & Screen Saver
###############################################################################
# Set a custom wallpaper image. `DefaultDesktop.jpg` is already a symlink, and
# all wallpapers are in `/Library/Desktop Pictures/`. The default is `Wave.jpg`.
#rm -rf ~/Library/Application Support/Dock/desktoppicture.db
#sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg
#sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg
# Start after begin idle for time (in seconds)
defaults -currentHost write com.apple.screensaver idleTime -int 300
# Show with clock
defaults -currentHost write com.apple.screensaver showClock -bool true
###############################################################################
# Date & Time
###############################################################################
# Set the timezone; see `systemsetup -listtimezones` for other values
sudo systemsetup -settimezone "Europe/Tallinn" > /dev/null
# Set date and time automatically
sudo systemsetup -setusingnetworktime on > /dev/null
# Set time server
sudo systemsetup -setnetworktimeserver "time.apple.com" > /dev/null
# Set time zome automatically using current location
sudo defaults write /Library/Preferences/com.apple.timezone.auto.plist Active -bool true
# Menu bar clock format
# "h:mm" Default
# "HH" Use a 24-hour clock
# "a" Show AM/PM
# "ss" Display the time with seconds
defaults write com.apple.menuextra.clock DateFormat -string "HH"
# Flash the time separators
defaults write com.apple.menuextra.clock FlashDateSeparators -bool false
# Analog menu bar clock
defaults write com.apple.menuextra.clock IsAnalog -bool false
###############################################################################
# Safari & WebKit #
###############################################################################
# Press Tab to highlight each item on a web page
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# Enable Safari’s debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Make Safari’s search banners default to Contains instead of Starts With
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
# Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
# Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
###############################################################################
# Terminal #
###############################################################################
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
###############################################################################
# Activity Monitor
###############################################################################
# Show the main window when launching Activity Monitor
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
# Visualize CPU usage in the Activity Monitor Dock icon
# defaults write com.apple.ActivityMonitor IconType -int 5
# Show processes in Activity Monitor
# 100: All Processes
# 101: All Processes, Hierarchally
# 102: My Processes
# 103: System Processes
# 104: Other User Processes
# 105: Active Processes
# 106: Inactive Processes
# 106: Inactive Processes
# 107: Windowed Processes
defaults write com.apple.ActivityMonitor ShowCategory -int 100
# Sort Activity Monitor results by CPU usage
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0
# Update Frequency (in seconds)
# 1: Very often (1 sec)
# 2: Often (2 sec)
# 5: Normally (5 sec)
defaults write com.apple.ActivityMonitor UpdatePeriod -int 2
# Show Data in the Disk graph (instead of IO)
defaults write com.apple.ActivityMonitor DiskGraphType -int 1
# Show Data in the Network graph (instead of packets)
defaults write com.apple.ActivityMonitor NetworkGraphType -int 1
# Change Dock Icon
# 0: Application Icon
# 2: Network Usage
# 3: Disk Activity
# 5: CPU Usage
# 6: CPU History
# defaults write com.apple.ActivityMonitor IconType -int 0
echo "Done. Note that some of these changes require a logout/restart to take effect."