Last active
February 10, 2021 19:44
-
-
Save mmcalli/9bd2db35900c187133d041d424a0b444 to your computer and use it in GitHub Desktop.
Example macOS configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Derived from Mathias Bynens' macos preferences | |
# 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 & | |
############################################################################### | |
# General UI/UX # | |
############################################################################### | |
# Expand save panel by default | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expand print panel by default | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -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 | |
# Remove duplicates in the “Open With” menu (also see `lscleanup` alias) | |
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user | |
# Display ASCII control characters using caret notation in standard text views | |
# Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt` | |
defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true | |
# Disable Resume system-wide | |
defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false | |
# Reveal IP address, hostname, OS version, etc. when clicking the clock | |
# in the login window | |
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName | |
# Restart automatically if the computer freezes | |
sudo systemsetup -setrestartfreeze on | |
# Never go into computer sleep mode | |
sudo systemsetup -setcomputersleep Off > /dev/null | |
# Disable smart quotes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false | |
# Disable smart dashes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false | |
############################################################################### | |
# Trackpad, mouse, keyboard, Bluetooth accessories, and input # | |
############################################################################### | |
# Increase sound quality for Bluetooth headphones/headsets | |
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 | |
# Enable full keyboard access for all controls | |
# (e.g. enable Tab in modal dialogs) | |
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 | |
# Set language and text formats | |
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with | |
# `Inches`, `en_GB` with `en_US`, and `true` with `false`. | |
defaults write NSGlobalDomain AppleLanguages -array "en" | |
defaults write NSGlobalDomain AppleLocale -string "en_US@currency=USD" | |
defaults write NSGlobalDomain AppleMeasurementUnits -string "Inches" | |
defaults write NSGlobalDomain AppleMetricUnits -bool false | |
############################################################################### | |
# Screen # | |
############################################################################### | |
# 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 | |
# Save screenshots to the desktop | |
defaults write com.apple.screencapture location -string "${HOME}/Desktop" | |
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) | |
defaults write com.apple.screencapture type -string "png" | |
# Disable shadow in screenshots | |
defaults write com.apple.screencapture disable-shadow -bool true | |
# Enable subpixel font rendering on non-Apple LCDs | |
defaults write NSGlobalDomain AppleFontSmoothing -int 2 | |
############################################################################### | |
# Finder # | |
############################################################################### | |
# Set Desktop as the default location for new Finder windows | |
# For other paths, use `PfLo` and `file:///full/path/here/` | |
defaults write com.apple.finder NewWindowTarget -string "PfDe" | |
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/" | |
# Show icons for hard drives, servers, and removable media on the desktop | |
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true | |
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true | |
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true | |
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true | |
# Finder: show hidden files by default | |
defaults write com.apple.finder AppleShowAllFiles -bool true | |
# Finder: show all filename extensions | |
defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
# Finder: show status bar | |
defaults write com.apple.finder ShowStatusBar -bool true | |
# Finder: show path bar | |
defaults write com.apple.finder ShowPathbar -bool true | |
# Display full POSIX path as Finder window title | |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true | |
# Keep folders on top when sorting by name | |
defaults write com.apple.finder _FXSortFoldersFirst -bool true | |
# When performing a search, search the current folder by default | |
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" | |
# Disable the warning when changing a file extension | |
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false | |
# Enable spring loading for directories | |
defaults write NSGlobalDomain com.apple.springing.enabled -bool true | |
# Remove the spring loading delay for directories | |
defaults write NSGlobalDomain com.apple.springing.delay -float 0 | |
# Avoid creating .DS_Store files on network or USB volumes | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# Automatically open a new Finder window when a volume is mounted | |
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true | |
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true | |
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true | |
# Use list view in all Finder windows by default | |
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv` | |
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" | |
# Disable the warning before emptying the Trash | |
defaults write com.apple.finder WarnOnEmptyTrash -bool false | |
# Show the ~/Library folder | |
chflags nohidden ~/Library | |
# Show the /Volumes folder | |
sudo chflags nohidden /Volumes | |
# Expand the following File Info panes: | |
# “General”, “Open with”, and “Sharing & Permissions” | |
defaults write com.apple.finder FXInfoPanesExpanded -dict \ | |
General -bool true \ | |
OpenWith -bool true \ | |
Privileges -bool true | |
############################################################################### | |
# Dock, Dashboard, and hot corners # | |
############################################################################### | |
# Enable spring loading for all Dock items | |
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true | |
# Stop the Dock moving monitor | |
defaults write com.apple.Dock position-immutable -bool yes | |
############################################################################### | |
# 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 all processes in Activity Monitor | |
defaults write com.apple.ActivityMonitor ShowCategory -int 0 | |
# Sort Activity Monitor results by CPU usage | |
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" | |
defaults write com.apple.ActivityMonitor SortDirection -int 0 | |
############################################################################### | |
# Mac App Store # | |
############################################################################### | |
# 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 | |
############################################################################### | |
# Photos # | |
############################################################################### | |
# Prevent Photos from opening automatically when devices are plugged in | |
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true | |
############################################################################### | |
# Google Chrome & Google Chrome Canary # | |
############################################################################### | |
# Disable the all too sensitive backswipe on trackpads | |
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false | |
defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false | |
# Disable the all too sensitive backswipe on Magic Mouse | |
defaults write com.google.Chrome AppleEnableMouseSwipeNavigateWithScrolls -bool false | |
defaults write com.google.Chrome.canary AppleEnableMouseSwipeNavigateWithScrolls -bool false | |
# Use the system-native print preview dialog | |
defaults write com.google.Chrome DisablePrintPreview -bool true | |
defaults write com.google.Chrome.canary DisablePrintPreview -bool true | |
# Expand the print dialog by default | |
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true | |
defaults write com.google.Chrome.canary PMPrintingExpandedStateForPrint2 -bool true | |
############################################################################### | |
# Sublime Text # | |
############################################################################### | |
# Make Sublime Text the default text editor | |
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}' | |
############################################################################### | |
# Git # | |
############################################################################### | |
# Make Beyond Compare the git difftool and merge tool | |
git config --global diff.tool bc3 | |
git config --global merge.tool bc3 | |
git config --global mergetool.bc3.trustExitCode true | |
############################################################################### | |
# Kill affected applications # | |
############################################################################### | |
for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \ | |
"Dock" "Finder" "Google Chrome" "Google Chrome Canary" \ | |
"Photos" "SystemUIServer" "Terminal" "iCal"; do | |
killall "${app}" &> /dev/null | |
done | |
echo "Done. Note that some of these changes require a logout/restart to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment