2014-10-23 16:42:28 -06:00
# Ask for the administrator password upfront
sudo -v
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 " $$ " || exit; done 2>/dev/null &
2014-11-10 04:37:59 -07:00
echo "Configuring osx."
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# General UI/UX #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-11-10 04:37:59 -07:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.08
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable Resume system-wide
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable automatic termination of inactive apps
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Set Help Viewer windows to non-floating mode
defaults write com.apple.helpviewer DevMode -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Restart automatically if the computer freezes
systemsetup -setrestartfreeze on
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Never go into computer sleep mode
systemsetup -setcomputersleep Off > /dev/null
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable full keyboard access for all controls
# (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable access for assistive devices
echo -n 'a' | sudo tee /private/var/db/.AccessibilityAPIEnabled > /dev/null 2>& 1
sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled
# TODO: avoid GUI password prompt somehow (http://apple.stackexchange.com/q/60476/4408)
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Use scroll gesture with the Ctrl (^) modifier key to zoom
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
# Follow the keyboard focus while zoomed in
defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Automatically illuminate built-in MacBook keyboard in low light
defaults write com.apple.BezelServices kDim -bool true
# Turn off keyboard illumination when computer is not used for 5 minutes
defaults write com.apple.BezelServices kDimTime -int 300
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Set language and text formats
# Note: if you’ re in the US, replace `EUR` with `USD`, `Centimeters` with
# `Inches`, 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Screen #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Save screenshots to the desktop
defaults write com.apple.screencapture location -string " $HOME /Desktop "
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
# Disable shadow in screenshots
defaults write com.apple.screencapture disable-shadow -bool true
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable HiDPI display modes (requires restart)
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Finder #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Finder: show hidden files by default
defaults write com.apple.finder AppleShowAllFiles -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Finder: allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Show item info near icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c " Set :DesktopViewSettings:IconViewSettings:showItemInfo true " ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Show item info to the right of the icons on the desktop
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Increase grid spacing for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Increase the size of icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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"
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Don't Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable AirDrop over Ethernet and on unsupported Macs running Lion
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Show the ~/Library folder
chflags nohidden ~/Library
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Remove Dropbox’ s green checkmark icons in Finder
file = /Applications/Dropbox.app/Contents/Resources/check.icns
[ -e " $file " ] && mv -f " $file " " $file .bak "
unset file
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Dock & hot corners #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable highlight hover effect for the grid view of a stack (Dock)
defaults write com.apple.dock mouse-over-hilite-stack -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Set the icon size of Dock items to 36 pixels
defaults write com.apple.dock tilesize -int 36
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable spring loading for all Dock items
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Show indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Don’ t 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
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Don’ t show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Remove the auto-hiding Dock delay
defaults write com.apple.Dock autohide-delay -float 0
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable the 2D Dock
#defaults write com.apple.dock no-glass -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Reset Launchpad
find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Hot corners
# Possible values:
# 0: no-op
# 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
# Top right screen corner → Desktop
defaults write com.apple.dock wvous-tr-corner -int 0
defaults write com.apple.dock wvous-tr-modifier -int 0
defaults write com.apple.dock wvous-bl-corner -int 0
defaults write com.apple.dock wvous-bl-modifier -int 0
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Time Machine #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
# Disable local Time Machine backups
hash tmutil & > /dev/null && sudo tmutil disablelocal
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
###############################################################################
2011-09-05 12:08:58 -06:00
2014-10-23 16:42:28 -06:00
# Enable the debug menu in Disk Utility
defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true
defaults write com.apple.DiskUtility advanced-image-options -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Mac App Store #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable the WebKit Developer Tools in the Mac App Store
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Enable Debug Menu in the Mac App Store
defaults write com.apple.appstore ShowDebugMenu -bool true
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Google Chrome & Google Chrome Canary #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Allow installing user scripts via GitHub or Userscripts.org
defaults write com.google.Chrome ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*"
defaults write com.google.Chrome.canary ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*"
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
###############################################################################
# Transmission.app #
###############################################################################
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Use `~/Documents/Torrents` to store incomplete downloads
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
defaults write org.m0k.transmission IncompleteDownloadFolder -string " ${ HOME } /Documents/Torrents "
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# Don’ t prompt for confirmation before downloading
defaults write org.m0k.transmission DownloadAsk -bool false
2011-09-05 12:19:31 -06:00
2014-10-23 16:42:28 -06:00
# 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
2014-11-10 04:37:59 -07:00
echo "Finished successfully."