Skip to content

Instantly share code, notes, and snippets.

@edsonaj
Created August 12, 2012 05:23

Revisions

  1. edsonaj created this gist Aug 12, 2012.
    343 changes: 343 additions & 0 deletions osx.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,343 @@
    #!/bin/bash
    # Based on https://github.com/mathiasbynens/dotfiles/blob/master/.osx

    ###############################################################################
    # General UI/UX #
    ###############################################################################

    # Set computer name (as done via System Preferences → Sharing)
    scutil --set ComputerName "Edson Alves Junior's MacBook Pro"
    scutil --set HostName "Edson Alves Junior's MacBook Pro"
    scutil --set LocalHostName "Jr-MBP"

    # Menu bar: Show remaining battery percentage
    defaults write com.apple.menuextra.battery ShowPercent -string "YES"

    # Menu bar: hide the useless Time Machine and Volume icons
    defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" "/System/Library/CoreServices/Menu Extras/AirPort.menu" "/System/Library/CoreServices/Menu Extras/Battery.menu" "/System/Library/CoreServices/Menu Extras/Clock.menu"

    # Expand save panel by default
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

    # Expand print panel by default
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true

    # Disable the “Are you sure you want to open this application?” dialog
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    # Increase window resize speed for Cocoa applications
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    # Disable Resume system-wide
    defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

    ###############################################################################
    # 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

    # Trackpad: swipe between pages with three fingers
    defaults write NSGlobalDomain AppleEnableSwipeNavigateWithScrolls -bool true
    defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerHorizSwipeGesture -int 1
    defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerHorizSwipeGesture -int 1

    # Disable “natural” (Lion-style) scrolling
    defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false

    # 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

    # 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

    # Set a blazingly fast keyboard repeat rate
    defaults write NSGlobalDomain KeyRepeat -int 0

    # 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" "nl"
    defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=USD"
    defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
    defaults write NSGlobalDomain AppleMetricUnits -bool true

    # Disable auto-correct
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -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"

    # Enable HiDPI display modes (requires restart)
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

    ###############################################################################
    # Finder #
    ###############################################################################

    # Allow quitting Finder via ⌘ + Q; doing so will also hide desktop icons
    defaults write com.apple.finder QuitMenuItem -bool true

    # Show status bar in Finder
    defaults write com.apple.finder ShowStatusBar -bool true

    # Finder: show hidden files by default
    defaults write com.apple.Finder AppleShowAllFiles -bool true

    # Allow text selection in Quick Look
    defaults write com.apple.finder QLEnableTextSelection -bool true

    # 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

    # Show 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

    # 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 true

    # Show item info below 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 :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist

    # Don't Display full POSIX path as Finder window title
    defaults write com.apple.finder _FXShowPosixPathInTitle false

    # Avoid creating .DS_Store files on network volumes
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true

    # Disable the warning when changing a file extension
    defaults write com.apple.finder FXEnableExtensionChangeWarning false

    # Disable the warning before emptying the Trash
    defaults write com.apple.finder WarnOnEmptyTrash -bool false

    # Enable AirDrop over Ethernet and on unsupported Macs running Lion
    defaults write com.apple.NetworkBrowser BrowseAllInterfaces true

    # Show the ~/Library folder
    chflags nohidden ~/Library

    # Set the default view in Finder to List
    defaults write com.apple.Finder FXPreferredViewStyle Nlsv

    # Increase the File Name Displayed Character Limit in Mac OS X
    defaults write com.apple.finder FXDesktopLayoutGridCharCount 50

    ###############################################################################
    # Dock & hot corners #
    ###############################################################################

    # Enable highlight hover effect for the grid view of a stack (Dock)
    defaults write com.apple.dock mouse-over-hilte-stack -bool true

    # Set the icon size of Dock items to 36 pixels
    defaults write com.apple.dock tilesize -int 36

    # Enable spring loading for all Dock items
    defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true

    # Don’t animate opening applications from the Dock
    defaults write com.apple.dock launchanim -bool false

    # Speed up Mission Control animations
    defaults write com.apple.dock expose-animation-duration -float 0.1

    # Show a Full Size Window Preview in Mission Control
    defaults write com.apple.dock expose-cluster-scale -float 0.6

    # Don't group windows by application in Mission Control
    defaults write com.apple.dock "expose-group-by-app" -bool false

    # Hide indicator lights for open applications in the Dock
    defaults write com.apple.dock show-process-indicators -bool false

    # Make Dock icons of hidden applications translucent
    defaults write com.apple.dock showhidden -bool true

    # Enable iTunes track notifications in the Dock
    defaults write com.apple.dock itunes-notifications -bool true

    # Add a spacer to the left side of the Dock (where the applications are)
    # defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' ;killall Dock
    # Add a spacer to the right side of the Dock (where the Trash is)
    # defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}' ;killall Dock

    # Reset Launchpad
    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete

    # Show Only Currently Active Apps in the Mac OS X Dock
    # defaults write com.apple.dock static-only -bool TRUE

    ###############################################################################
    # Safari & WebKit #
    ###############################################################################

    # Disable Safari’s thumbnail cache for History and Top Sites
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    # Remove useless icons from Safari’s bookmarks bar
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    # 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

    # Remove useless icons from Safari’s bookmarks bar
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    # 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

    ###############################################################################
    # Address Book, Dashboard, iCal, iTunes, Mail, and Disk Utility #
    ###############################################################################

    # Enable the debug menu in Address Book
    defaults write com.apple.addressbook ABShowDebugMenu -bool true

    # Enable Dashboard dev mode (allows keeping widgets on the desktop)
    defaults write com.apple.dashboard devmode -bool true

    # Enable the debug menu in iCal
    defaults write com.apple.iCal IncludeDebugMenu -bool true

    # Disable the Ping sidebar in iTunes
    defaults write com.apple.iTunes disablePingSidebar -bool true

    # Disable all the other Ping stuff in iTunes
    defaults write com.apple.iTunes disablePing -bool true

    # Make ⌘ + F focus the search input in iTunes
    defaults write com.apple.iTunes NSUserKeyEquivalents -dict-add "Target Search Field" "@F"

    # Disable send and reply animations in Mail.app
    defaults write com.apple.Mail DisableReplyAnimations -bool true
    defaults write com.apple.Mail DisableSendAnimations -bool true

    # Copy email addresses as `[email protected]` instead of `Foo Bar <[email protected]>` in Mail.app
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    # Enable the debug menu in Disk Utility
    defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true

    # Enable Half-Star Ratings in iTunes
    defaults write com.apple.iTunes allow-half-stars -bool TRUE

    # Enable the iTunes song & artist Dock icon popups
    defaults write com.apple.dock itunes-notifications -bool TRUE

    # Jump to the Most Recently Used Desktop Space with a Hidden Gesture in OS X Lion (4 Finger Tap)
    defaults write com.apple.dock double-tap-jump-back -bool TRUE;killall Dock

    ###############################################################################
    # Terminal #
    ###############################################################################

    # Only use UTF-8 in Terminal.app
    defaults write com.apple.terminal StringEncodings -array 4

    # Enable “focus follows mouse” for Terminal.app and all X11 apps
    # This means you can hover over a window and start typing in it without clicking first
    defaults write com.apple.terminal FocusFollowsMouse -bool true
    defaults write org.x.X11 wm_ffm -bool true

    ###############################################################################
    # Time Machine #
    ###############################################################################

    # Prevent Time Machine from prompting to use new hard drives as backup volume
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true

    # Disable local Time Machine backups
    hash tmutil &> /dev/null && sudo tmutil disablelocal

    # Backup each 30 minutes
    sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800

    # Unsupported Drives
    defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

    ###############################################################################
    # Twitter.app #
    ###############################################################################

    # Disable smart quotes as it’s annoying for code tweets
    defaults write com.twitter.twitter-mac AutomaticQuoteSubstitutionEnabled -bool false

    # Show the app window when clicking the menu icon
    defaults write com.twitter.twitter-mac MenuItemBehavior -int 1

    # Enable the hidden ‘Develop’ menu
    defaults write com.twitter.twitter-mac ShowDevelopMenu -bool true

    # Open links in the background
    defaults write com.twitter.twitter-mac openLinksInBackground -bool true

    # Allow closing the ‘new tweet’ window by pressing `Esc`
    defaults write com.twitter.twitter-mac ESCClosesComposeWindow -bool true

    # Show full names rather than Twitter handles
    defaults write com.twitter.twitter-mac ShowFullNames -bool true

    # Hide the app in the background if it’s not the front-most window
    defaults write com.twitter.twitter-mac HideInBackground -bool true

    ###############################################################################
    # Parallels #
    ###############################################################################

    # Disable Ads in Parallels Desktop
    defaults write com.parallels.Parallels\ Desktop ProductPromo.ForcePromoOff -bool YES

    ###############################################################################
    # Chrome #
    ###############################################################################

    # Open OSX Print Panel
    defaults write com.google.Chrome NSUserKeyEquivalents -dict-add "Print Using System Dialog..." "@p" "Print..." "~@p"

    ###############################################################################
    # Kill affected applications #
    ###############################################################################

    for app in Finder Dock Mail Safari iTunes iCal Address\ Book SystemUIServer Twitter; do
    killall "$app" > /dev/null 2>&1
    done
    killall Dock
    echo "Done. Note that some of these changes require a logout/restart to take effect."