-
Notifications
You must be signed in to change notification settings - Fork 0
/
macos.sh
executable file
·213 lines (161 loc) · 7.14 KB
/
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
#!/usr/bin/env bash
# ~/.macos — https://mths.be/macos
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
# Disable automatic capitalization as it’s annoying when typing code
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
# Disable smart dashes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Disable automatic period substitution as it’s annoying when typing code
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
# Disable smart quotes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Allow quitting Finder via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
# Show all filename extensions in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true
# Show the ~/Library folder
chflags nohidden ~/Library
softwareupdate --schedule on
# Enable the automatic update check
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Download newly available updates in background
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
# Install System data files & security updates
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
# Turn on app auto-update
defaults write com.apple.commerce AutoUpdate -bool true
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Add a shortcut for deleting messages
defaults write com.apple.MobileSMS.plist NSUserKeyEquivalents -dict 'Delete Conversation...' '@\U007F'
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
if [[ $(uname -m) != 'arm64' ]]; then
# Switch option with command
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000E2,"HIDKeyboardModifierMappingDst":0x7000000E3},{"HIDKeyboardModifierMappingSrc":0x7000000E3,"HIDKeyboardModifierMappingDst":0x7000000E2}]}'
# Reverse scroll for mouse
defaults write -g com.apple.swipescrolldirection -bool false
fi
# Show 24 hours clock
defaults write com.apple.menuextra.clock Show24Hour -int 1
# Don't show siri in menubar
defaults write com.apple.Siri StatusMenuVisible -int 0
# Don't show spotlight in menubar
defaults -currentHost write com.apple.Spotlight MenuItemHidden -int 1
# Don't rearrange Spaces
defaults write com.apple.dock "mru-spaces" -int 0
# Saves screenshots into its own folder
mkdir -p ${HOME}/Pictures/Screenshots
defaults write com.apple.screencapture location -string "${HOME}/Pictures/Screenshots"
# Size of dock
defaults write com.apple.dock tilesize -int 55
# auto hide dock
defaults write com.apple.dock autohide -bool true
# Disabling password hints on the lock screen
defaults write com.apple.loginwindow RetriesUntilHint -int 0
# Keyboard > Shortcuts > Spotlight > Show Spotlight search, disable
# Note: Replacing it with Raycast https://raycastapp.notion.site/Hotkey-56103210375b4fc78b63a7c5e7075fb7
defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 64 "
<dict>
<key>enabled</key><false/>
</dict>
"
# Keyboard > Shortcuts > Spotlight > Show Finder search window, disable
# Note: Replacing it with Raycast https://raycastapp.notion.site/Hotkey-56103210375b4fc78b63a7c5e7075fb7
defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 65 "
<dict>
<key>enabled</key><false/>
</dict>
"
# Keyboard > Shortcuts > Screenshots > Save picture of screen as file, disable
# Note: Replacing it with CleanShotX
defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 28 "
<dict>
<key>enabled</key><false/>
</dict>
"
# Keyboard > Shortcuts > Screenshots > Save picture of selected area as file, disable
# Note: Replacing it with CleanShotX
defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 30 "
<dict>
<key>enabled</key><false/>
</dict>
"
# wake the machine when the laptop lid (or clamshell) is opened
sudo pmset -a lidwake 1
# display sleep timer
sudo pmset -a displaysleep 10
# Disable machine sleep while charging
sudo pmset -c sleep 0
# Set machine sleep to 10 minutes on battery
sudo pmset -b sleep 15
# Enable firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw \
--setblockall off \
--setallowsigned on \
--setallowsignedapp on \
--setloggingmode on \
--setstealthmode on \
--setglobalstate on
# disable ARD
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate
# Set up dock
TO_REMOVE_FROM_DOCK=(
"FaceTime"
"com.apple.mail"
"com.apple.TV"
"com.apple.freeform"
"com.apple.reminders"
"com.apple.iCal"
"com.apple.Music"
"com.apple.Safari"
"com.apple.AddressBook"
"com.apple.Maps"
"com.apple.iWork.Keynote"
"com.apple.iWork.Numbers"
"com.apple.iWork.Pages"
)
for item in "${TO_REMOVE_FROM_DOCK[@]}"; do
/opt/homebrew/bin/dockutil --remove "$item" --no-restart
done
/opt/homebrew/bin/dockutil --add "/Applications/iTerm.app" --after "com.apple.Notes" --no-restart
/opt/homebrew/bin/dockutil --add "/Applications/Visual Studio Code.app" --after "com.apple.Notes" --no-restart
/opt/homebrew/bin/dockutil --add "/Applications/Google Chrome.app" --after "com.apple.Notes" --no-restart
/opt/homebrew/bin/dockutil --add "/Applications/Fantastical.app" --after "com.apple.MobileSMS"
# Enable FileVault
sudo fdesetup enable -user $(whoami)
killall -9 SystemUIServer
killall -9 Dock
a