Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
380 lines (267 sloc) 13.9 KB
#!/usr/bin/env bash
# Havily based on mathiasbynens's ~/.osx:
echo "• Updating OS X defaults"
# --[ Systemwide ]--
# 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
# Disable «smart» quotes and «smart» dashes
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Enable full keyboard access for all controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Enable "Ask to keep changes when closing documents"
defaults write NSGlobalDomain NSCloseAlwaysConfirmsChanges -bool false
# Disable "close windows when quitting an app"
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true
# Enable Graphite appearance
defaults write NSGlobalDomain AppleAquaColorVariant -int 6
# Use dark menubar and Dock
defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark"
# Click in the scroll bar: Jump to the spot that's clicked
defaults write NSGlobalDomain AppleScrollerPagingBehavior -int 1
# Always prefer tabs to windows when opening documents
defaults write NSGlobalDomain AppleWindowTabbingMode -string "always"
# Disable Sound Effects on Boot
sudo nvram SystemAudioVolume=" "
# Enable Application layer firewall, logging and "stealth mode"
sudo defaults write /Library/Preferences/ globalstate -int 1
sudo defaults write /Library/Preferences/ allowsignedenabled -bool false
sudo defaults write /Library/Preferences/ loggingenabled -bool true
sudo defaults write /Library/Preferences/ stealthenabled -bool true
# Don't open any apps when attaching a "camera"
defaults -currentHost write disableHotPlug -bool YES
# --[ Locale ]--
# I use Russian units in English with USD for currency
defaults write NSGlobalDomain AppleLocale -string "en_RU@currency=USD"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -int 1
defaults write NSGlobalDomain Country -string "US"
# Use English and Russian languagues, in this particular order
defaults write NSGlobalDomain AppleLanguages -array en-US ru-RU
# --[ Trackpad ]--
# Enable tap to click
defaults write Clicking -bool true
defaults write NSGlobalDomain -int 1
# Enable three finger drag
defaults write TrackpadThreeFingerDrag -bool true
# --[ Finder ]--
# Set $HOME as the default Finder window location
defaults write NewWindowTarget -string "PfHm"
defaults write NewWindowTargetPath -string "file://${HOME}/Documents/"
# Expand the following File Info panes:
# “General”, “Open with”, and “Sharing & Permissions”
defaults write FXInfoPanesExpanded -dict \
General -bool true \
OpenWith -bool true \
Privileges -bool true
# Don't show much on my desktop
defaults write ShowExternalHardDrivesOnDesktop -bool true
defaults write ShowHardDrivesOnDesktop -bool false
defaults write ShowMountedServersOnDesktop -bool false
defaults write ShowRemovableMediaOnDesktop -bool true
# Show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Show status bar
defaults write ShowStatusBar -bool true
# Hide path bar
defaults write ShowPathbar -bool false
# Allow text selection in Quick Look
# FIXME(rodionovd): doesn't work on 10.11 El Capitan (rdar://23062430)
defaults write QLEnableTextSelection -bool true
# When performing a search, search the current folder by default
defaults write FXDefaultSearchScope -string "SCcf"
# Enable spring loading for directories
defaults write NSGlobalDomain -bool true
# Tune the spring loading delay for directories
defaults write NSGlobalDomain -float 0.1f
# Avoid creating .DS_Store files on network volumes
defaults write DSDontWriteNetworkStores -bool true
# Disable the warning when changing a file extension
defaults write FXEnableExtensionChangeWarning -bool false
# Show the ~/Library folder
chflags nohidden ~/Library
# Force usage of Finder's list view
defaults write FXPreferredViewStyle -string "Nlsv"
# Desktop icons size
$PLISTBUDDY -c "Set :DesktopViewSettings:IconViewSettings:iconSize 36" $FILE
# Desktop labels size
$PLISTBUDDY -c "Set :DesktopViewSettings:IconViewSettings:textSize 12" $FILE
# Always show icon previews
$PLISTBUDDY -c "Set :DesktopViewSettings:IconViewSettings:showIconPreview true" $FILE
# --[ Dock ]--
# Set Dock to appear on the right
defaults write orientation -string right
# Disable Dock icon magnification
defaults write magnification -bool false
# Autohide Dock
defaults write autohide -bool true
defaults write autohide-delay -float 0
# Set the icon size of Dock items
defaults write tilesize -int 16
# --[ Safary ]--
# Disable Java
defaults write WebKitJavaEnabled -bool false
defaults write -bool false
# Disable plug-ins
defaults write WebKitPluginsEnabled -bool false
defaults write -bool false
# Enable “Do Not Track”
defaults write SendDoNotTrackHTTPHeader -bool true
# Block pop-up windows
defaults write WebKitJavaScriptCanOpenWindowsAutomatically -bool false
defaults write -bool false
# Privacy: don’t send search queries to Apple
defaults write UniversalSearchEnabled -bool false
defaults write SuppressSearchSuggestions -bool true
# Press Tab to highlight each item on a web page
defaults write WebKitTabToLinksPreferenceKey -bool true
defaults write -bool true
# Show the full URL in the address bar (note: this still hides the scheme)
defaults write ShowFullURLInSmartSearchField -bool true
# Prevent Safari from opening ‘safe’ files automatically after downloading
defaults write AutoOpenSafeDownloads -bool false
# Hide Safari’s bookmarks bar by default
defaults write ShowFavoritesBar -bool false
# Hide Safari’s sidebar in Top Sites
defaults write ShowSidebarInTopSites -bool false
# Enable the Develop menu and the Web Inspector
defaults write IncludeDevelopMenu -bool true
defaults write WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write -bool true
# Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Make Safari’s search banners default to Contains instead of Starts With
defaults write FindOnPageMatchesWordStartsOnly -bool false
# Do not preload Top Hits in the background
defaults write PreloadTopHit -bool false
# Show status bar
defaults write ShowOverlayStatusBar -bool true
# --[ Activity Monitor ]--
# Show the main window when launching Activity Monitor
defaults write OpenMainWindow -bool true
# Show all processes in Activity Monitor
defaults write ShowCategory -int 0
# Sort Activity Monitor results by CPU usage
defaults write SortColumn -string "CPUUsage"
defaults write SortDirection -int 0
# --[ TextEdit ]--
# Use plain text mode for new TextEdit documents
defaults write RichText -int 0
# Open and save files as UTF-8 in TextEdit
defaults write PlainTextEncoding -int 4
defaults write PlainTextEncodingForWrite -int 4
# --[ Messages ]--
# Disable automatic emoji substitution (i.e. use plain text smileys)
defaults write SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
# --[ Time Machine ]---
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write DoNotOfferNewDisksForBackup -bool true
# Disable local Time Machine backups
sudo tmutil disablelocal
# --[ Xcode ]--
# Trim trailing whitespace
defaults write DVTTextEditorTrimTrailingWhitespace -bool true
# Trim whitespace only lines
defaults write DVTTextEditorTrimWhitespaceOnlyLines -bool true
# Show line numbers
defaults write DVTTextShowLineNumbers -bool true
# Show ruler at 100 chars
defaults write DVTTextShowPageGuide -bool true
defaults write DVTTextPageGuideLocation -int 100
# Disable source control
defaults write IDESourceControlEnableSourceControl_7_1 -bool false
# Show build times in toolbar
defaults write ShowBuildOperationDuration -bool true
# Use Sunset color theme
defaults write DVTFontAndColorCurrentTheme -string "Sunset.dvtcolortheme"
# Power!
defaults write IDEBuildOperationMaxNumberOfConcurrentCompileTasks -int `sysctl -n hw.ncpu`
# -- [ Mail ]--
# Don't load remote content by default
defaults write DisableURLLoading -bool true
# -- [ Transmission ]--
# Trash original torrent files
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
# Hide the donate message
defaults write org.m0k.transmission WarningDonate -bool false
# Hide the legal disclaimer
defaults write org.m0k.transmission WarningLegal -bool false
# IP block list.
# Source:
defaults write org.m0k.transmission BlocklistURL -string ""
defaults write org.m0k.transmission BlocklistAutoUpdate -bool true
# --[ Network ]--
# Use OpenDNS servers
sudo networksetup -setdnsservers Wi-Fi
# -- [Keyboard and Trackpad ]--
# Select next source in input menu with ⌘Space
# Reset existing entry (if any)
$PLISTBUDDY -c "delete :AppleSymbolicHotKeys:60" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60 dict" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:enabled bool YES" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value dict" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value:parameters array" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value:parameters:0 integer 32" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value:parameters:1 integer 49" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value:parameters:2 integer 1048576" $FILE
$PLISTBUDDY -c "add :AppleSymbolicHotKeys:60:value:type string standard" $FILE
# --[ Menubar ]--
# Always display Volume menubar item
$PLISTBUDDY -c "add :menuExtras:0 string '/System/Library/CoreServices/Menu Extras/'" $FILE
# -- [ Login Items ]--
function add_login_item {
osascript -e "tell application \"System Events\" to make login item at end with properties {path: \"$1\", hidden:true}"
add_login_item "/Applications/"
add_login_item "/Applications/"
add_login_item "/Applications/"
add_login_item "/Applications/"
add_login_item "/Applications/"
# TODO: notifications (Notifications.prefPane && /usr/sbin/usernoted)
# TODO: notification center widgets (
# ============================================================
# Apply the changes
# Force re-syncing of new preferences
killall cfprefsd
for app in "Activity Monitor" "Finder" "Messages" "Safari" "SystemUIServer" "Xcode"; do
killall "${app}" > /dev/null 2>&1
for app in "Safari"; do
open -a "${app}"
# ============================================================
# Software Updates
echo "• Install all available software updates"
if softwareupdate -l 2>&1 | grep $Q "No new software available."; then
echo "Your system is up to date 🌟"
sudo softwareupdate --install --all
# ============================================================
# Full-disk encryption
# Courtesy of MikeMcQuaid:
if fdesetup status | grep $Q -E "FileVault is (On|Off, but will be enabled after the next restart)."; then
echo "• Full-disk encryption is already enabled or will be enabled after the next restart"
echo "• Enabling full-disk encryption (FileVault)"
sudo fdesetup enable -user "$USER" | tee ~/Desktop/"FileVault_Recovery_Key.txt"
echo "⚠️ Full-disk encryption will be enabled after the next restart"