Skip to content

Instantly share code, notes, and snippets.

@WarpEngineer
Forked from brandonb927/osx-for-hackers.sh
Created November 20, 2014 16:06
Show Gist options
  • Save WarpEngineer/908322d8b0f401761791 to your computer and use it in GitHub Desktop.
Save WarpEngineer/908322d8b0f401761791 to your computer and use it in GitHub Desktop.

Revisions

  1. WarpEngineer revised this gist Nov 20, 2014. No changes.
  2. Brandon Brown revised this gist Nov 20, 2014. 1 changed file with 28 additions and 6 deletions.
    34 changes: 28 additions & 6 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/sh

    # Some things taken from here
    # Alot of these configs have been taken from the various places
    # on the web, most from here
    # https://github.com/mathiasbynens/dotfiles/blob/master/.osx

    # Set the colours you can use
    @@ -224,15 +225,21 @@ case $response in
    *) break;;
    esac

    echo ""
    echo "Disable the menubar transparency? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.universalaccess reduceTransparency -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false


    ################################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    @@ -497,9 +504,14 @@ esac


    ###############################################################################
    # Safari & WebKit
    # Chrome, Safari, & WebKit
    ###############################################################################

    echo ""
    echo "Privacy: Don’t send search queries to Apple"
    defaults write com.apple.Safari UniversalSearchEnabled -bool false
    defaults write com.apple.Safari SuppressSearchSuggestions -bool true

    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false
    @@ -534,6 +546,16 @@ echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
    defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false

    echo ""
    echo "Using the system-native print preview dialog in Chrome"
    defaults write com.google.Chrome DisablePrintPreview -bool true
    defaults write com.google.Chrome.canary DisablePrintPreview -bool true


    ###############################################################################
    # Mail
  3. Brandon Brown revised this gist Nov 19, 2014. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -524,10 +524,6 @@ echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

    echo ""
    echo "Enabling the Develop menu and the Web Inspector in Safari"
    defaults write com.apple.Safari IncludeDevelopMenu -bool true
  4. Brandon Brown revised this gist Oct 28, 2014. 1 changed file with 15 additions and 9 deletions.
    24 changes: 15 additions & 9 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -274,7 +274,7 @@ echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

    echo ""
    echo "Disable display from automatically adjusting brightness"
    echo "Disable display from automatically adjusting brightness? (y/n)"
    read -r response
    case $response in
    [yY])
    @@ -304,17 +304,23 @@ defaults write com.apple.screensaver askForPasswordDelay -int 0

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    # Thanks https://github.com/omgmog
    read screenshot_location
    if [ -z "$1" ]
    echo ""
    if [ -z "${screenshot_location}" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    # If nothing specified, we default to ~/Desktop
    screenshot_location="${HOME}/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    # Otherwise we use input
    if [[ "${screenshot_location:0:1}" != "/" ]]
    then
    # If input doesn't start with /, assume it's relative to home
    screenshot_location="${HOME}/${screenshot_location}"
    fi
    fi
    echo "Setting location to ${screenshot_location}"
    defaults write com.apple.screencapture location -string "${screenshot_location}"

    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    @@ -690,4 +696,4 @@ for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
    done
  5. Brandon Brown revised this gist Oct 27, 2014. 1 changed file with 546 additions and 545 deletions.
    1,091 changes: 546 additions & 545 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -52,641 +52,642 @@ esac
    if ! $CONTINUE; then
    # Check if we're continuing and output a message if not
    cecho "Please go read the script, it only takes a few minutes" $red
    else
    # Here we go.. ask for the administrator password upfront and run a
    # keep-alive to update existing `sudo` time stamp until script has finished
    sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
    exit
    fi

    ###############################################################################
    # General UI/UX
    ###############################################################################
    # Here we go.. ask for the administrator password upfront and run a
    # keep-alive to update existing `sudo` time stamp until script has finished
    sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    echo "Would you like to set your computer name (as done via System Preferences >> Sharing)? (y/n)"
    read -r response
    case $response in
    [yY])
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME
    break;;
    *) break;;
    esac
    ###############################################################################
    # General UI/UX
    ###############################################################################

    echo ""
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons? (y/n)"
    read -r response
    case $response in
    [yY])
    # Get the system Hardware UUID and use it for the next menubar stuff
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu"
    done

    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"
    break;;
    *) break;;
    esac
    echo ""
    echo "Would you like to set your computer name (as done via System Preferences >> Sharing)? (y/n)"
    read -r response
    case $response in
    [yY])
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME
    break;;
    *) break;;
    esac

    echo ""
    echo "Hide the Spotlight icon? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    break;;
    *) break;;
    esac
    echo ""
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons? (y/n)"
    read -r response
    case $response in
    [yY])
    # Get the system Hardware UUID and use it for the next menubar stuff
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu"
    done

    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"
    break;;
    *) break;;
    esac

    echo ""
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
    echo ""
    echo "Hide the Spotlight icon? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    break;;
    *) break;;
    esac

    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
    echo ""
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

    echo ""
    echo "Save to disk, rather than iCloud, by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
    break;;
    *) break;;
    esac
    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

    echo ""
    echo "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
    echo ""
    echo "Save to disk, rather than iCloud, by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
    echo ""
    echo "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

    echo ""
    echo "Removing duplicates in the 'Open With' menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    echo ""
    echo "Disable smart quotes and smart dashes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Removing duplicates in the 'Open With' menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

    echo ""
    echo "Add ability to toggle between Light and Dark mode in Yosemite using ctrl+opt+cmd+t? (y/n)"
    # http://www.reddit.com/r/apple/comments/2jr6s2/1010_i_found_a_way_to_dynamically_switch_between/
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable smart quotes and smart dashes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Add ability to toggle between Light and Dark mode in Yosemite using ctrl+opt+cmd+t? (y/n)"
    # http://www.reddit.com/r/apple/comments/2jr6s2/1010_i_found_a_way_to_dynamically_switch_between/
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true
    break;;
    *) break;;
    esac

    ###############################################################################
    # General Power and Performance modifications
    ###############################################################################

    echo ""
    echo "Disable hibernation? (speeds up entering sleep mode) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a hibernatemode 0
    break;;
    *) break;;
    esac
    ###############################################################################
    # General Power and Performance modifications
    ###############################################################################

    echo ""
    echo "Remove the sleep image file to save disk space? (y/n)"
    echo "(If you're on a <128GB SSD, this helps but can have adverse affects on performance. You've been warned.)"
    read -r response
    case $response in
    [yY])
    sudo rm /Private/var/vm/sleepimage
    echo "Creating a zero-byte file instead"
    sudo touch /Private/var/vm/sleepimage
    echo "and make sure it can't be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable hibernation? (speeds up entering sleep mode) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a hibernatemode 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable the sudden motion sensor? (it's not useful for SSDs/current MacBooks) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a sms 0
    break;;
    *) break;;
    esac
    echo ""
    echo "Remove the sleep image file to save disk space? (y/n)"
    echo "(If you're on a <128GB SSD, this helps but can have adverse affects on performance. You've been warned.)"
    read -r response
    case $response in
    [yY])
    sudo rm /Private/var/vm/sleepimage
    echo "Creating a zero-byte file instead"
    sudo touch /Private/var/vm/sleepimage
    echo "and make sure it can't be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable system-wide resume? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable the sudden motion sensor? (it's not useful for SSDs/current MacBooks) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a sms 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400
    echo ""
    echo "Disable system-wide resume? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

    ################################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
    ################################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Enabling full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

    echo ""
    echo "Disabling press-and-hold for special keys in favor of key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
    echo ""
    echo "Enabling full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

    echo ""
    echo "Setting a blazingly fast keyboard repeat rate"
    defaults write NSGlobalDomain KeyRepeat -int 0
    echo ""
    echo "Disabling press-and-hold for special keys in favor of key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

    echo ""
    echo "Disable auto-correct? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Setting a blazingly fast keyboard repeat rate"
    defaults write NSGlobalDomain KeyRepeat -int 0

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5
    echo ""
    echo "Disable auto-correct? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300
    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5

    echo ""
    echo "Disable display from automatically adjusting brightness"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

    echo ""
    echo "Disable keyboard from automatically adjusting backlight brightness in low light? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Keyboard Enabled" -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable display from automatically adjusting brightness"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false
    break;;
    *) break;;
    esac

    ###############################################################################
    # Screen
    ###############################################################################
    echo ""
    echo "Disable keyboard from automatically adjusting backlight brightness in low light? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Keyboard Enabled" -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0
    ###############################################################################
    # Screen
    ###############################################################################

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi
    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi

    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi

    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Enabling HiDPI display modes (requires restart)"
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi

    ###############################################################################
    # Finder
    ###############################################################################
    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

    echo ""
    echo "Show icons for hard drives, servers, and removable media on the desktop? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Enabling HiDPI display modes (requires restart)"
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

    echo ""
    echo "Show hidden files in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    *) break;;
    esac
    ###############################################################################
    # Finder
    ###############################################################################

    echo ""
    echo "Show dotfiles in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    *) break;;
    esac
    echo ""
    echo "Show icons for hard drives, servers, and removable media on the desktop? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Show all filename extensions in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Show hidden files in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Show status bar in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder ShowStatusBar -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Show dotfiles in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    *) break;;
    esac

    echo ""
    echo "Display full POSIX path as Finder window title? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Show all filename extensions in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable the warning when changing a file extension? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Show status bar in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder ShowStatusBar -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Use column view in all Finder windows by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXPreferredViewStyle Clmv
    break;;
    *) break;;
    esac
    echo ""
    echo "Display full POSIX path as Finder window title? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Avoid creation of .DS_Store files on network volumes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable the warning when changing a file extension? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable disk image verification? (y/n)"
    read -r response
    case $response in
    [yY])
    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
    break;;
    *) break;;
    esac
    echo ""
    echo "Use column view in all Finder windows by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXPreferredViewStyle Clmv
    break;;
    *) break;;
    esac

    echo ""
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true
    echo ""
    echo "Avoid creation of .DS_Store files on network volumes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Enabling 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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist


    ###############################################################################
    # Dock & Mission Control
    ###############################################################################

    echo "Wipe all (default) app icons from the Dock? (y/n)"
    echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock persistent-apps -array
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable disk image verification? (y/n)"
    read -r response
    case $response in
    [yY])
    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
    break;;
    *) break;;
    esac

    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36
    echo ""
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true
    echo ""
    echo "Enabling 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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

    echo ""
    echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0
    break;;
    *) break;;
    esac

    ###############################################################################
    # Dock & Mission Control
    ###############################################################################

    ###############################################################################
    # Safari & WebKit
    ###############################################################################
    echo "Wipe all (default) app icons from the Dock? (y/n)"
    echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock persistent-apps -array
    break;;
    *) break;;
    esac

    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false
    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36

    echo ""
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false
    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true

    echo ""
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
    echo ""
    echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
    ###############################################################################
    # Safari & WebKit
    ###############################################################################

    echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"
    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false

    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
    echo ""
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false

    echo ""
    echo "Enabling 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
    echo ""
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
    echo ""
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

    ###############################################################################
    # Mail
    ###############################################################################
    echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    echo ""
    echo "Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

    echo ""
    echo "Enabling 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

    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

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

    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
    ###############################################################################
    # Mail
    ###############################################################################

    echo ""
    echo "Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

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

    echo ""
    echo "Prevent Time Machine from prompting to use new hard drives as backup volume? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    break;;
    *) break;;
    esac
    ###############################################################################
    # Terminal
    ###############################################################################

    echo ""
    echo "Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs) (y/n)"
    read -r response
    case $response in
    [yY])
    hash tmutil &> /dev/null && sudo tmutil disablelocal
    break;;
    *) break;;
    esac
    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"


    ###############################################################################
    # Messages #
    ###############################################################################
    ###############################################################################
    # Time Machine
    ###############################################################################

    echo ""
    echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Prevent Time Machine from prompting to use new hard drives as backup volume? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs) (y/n)"
    read -r response
    case $response in
    [yY])
    hash tmutil &> /dev/null && sudo tmutil disablelocal
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable continuous spell checking in Messages.app? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    break;;
    *) break;;
    esac

    ###############################################################################
    # Messages #
    ###############################################################################

    ###############################################################################
    # Transmission.app #
    ###############################################################################
    echo ""
    echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Do you use Transmission for torrenting? (y/n)"
    read -r response
    case $response in
    [yY])
    echo ""
    echo "Use `~/Downloads/Incomplete` to store incomplete downloads"
    defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    mkdir -p ~/Downloads/Incomplete
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"

    echo ""
    echo "Don't prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false

    echo ""
    echo "Trash original torrent files"
    defaults write org.m0k.transmission DeleteOriginalTorrent -bool true

    echo ""
    echo "Hide the donate message"
    defaults write org.m0k.transmission WarningDonate -bool false

    echo ""
    echo "Hide the legal disclaimer"
    defaults write org.m0k.transmission WarningLegal -bool false
    break;;
    *) break;;
    esac
    echo ""
    echo "Disable continuous spell checking in Messages.app? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    break;;
    *) break;;
    esac


    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice, and is it installed?"
    read -r response
    case $response in
    [yY])
    # Installing from homebrew cask does the following for you!
    # echo ""
    # echo "Linking Sublime Text for command line usage as subl"
    # ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    break;;
    *) break;;
    esac
    ###############################################################################
    # Transmission.app #
    ###############################################################################


    ###############################################################################
    # Kill affected applications
    ###############################################################################
    echo ""
    echo "Do you use Transmission for torrenting? (y/n)"
    read -r response
    case $response in
    [yY])
    echo ""
    echo "Use `~/Downloads/Incomplete` to store incomplete downloads"
    defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    mkdir -p ~/Downloads/Incomplete
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"

    echo ""
    cecho "Done!" $cyan
    echo ""
    echo ""
    cecho "################################################################################" $white
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect." $red
    cecho "Killing some open applications in order to take effect." $red
    echo ""
    echo ""
    echo "Don't prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false

    echo ""
    echo "Trash original torrent files"
    defaults write org.m0k.transmission DeleteOriginalTorrent -bool true

    echo ""
    echo "Hide the donate message"
    defaults write org.m0k.transmission WarningDonate -bool false

    echo ""
    echo "Hide the legal disclaimer"
    defaults write org.m0k.transmission WarningLegal -bool false
    break;;
    *) break;;
    esac


    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice, and is it installed?"
    read -r response
    case $response in
    [yY])
    # Installing from homebrew cask does the following for you!
    # echo ""
    # echo "Linking Sublime Text for command line usage as subl"
    # ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    break;;
    *) break;;
    esac


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

    echo ""
    cecho "Done!" $cyan
    echo ""
    echo ""
    cecho "################################################################################" $white
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect." $red
    cecho "Killing some open applications in order to take effect." $red
    echo ""

    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
    fi
    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
  6. Brandon Brown revised this gist Oct 22, 2014. 1 changed file with 18 additions and 6 deletions.
    24 changes: 18 additions & 6 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -391,6 +391,7 @@ else

    echo ""
    echo "Display full POSIX path as Finder window title? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    @@ -400,6 +401,7 @@ else

    echo ""
    echo "Disable the warning when changing a file extension? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    @@ -409,6 +411,7 @@ else

    echo ""
    echo "Use column view in all Finder windows by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder FXPreferredViewStyle Clmv
    @@ -418,6 +421,7 @@ else

    echo ""
    echo "Avoid creation of .DS_Store files on network volumes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    @@ -427,6 +431,7 @@ else

    echo ""
    echo "Disable disk image verification? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.frameworks.diskimages skip-verify -bool true
    @@ -453,6 +458,7 @@ else

    echo "Wipe all (default) app icons from the Dock? (y/n)"
    echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock persistent-apps -array
    @@ -471,6 +477,7 @@ else

    echo ""
    echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.dock autohide -bool true
    @@ -550,7 +557,8 @@ else

    echo ""
    echo "Prevent Time Machine from prompting to use new hard drives as backup volume? (y/n)"
    case $response in
    read -r response
    case $response in
    [yY])
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    break;;
    @@ -559,7 +567,8 @@ else

    echo ""
    echo "Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs) (y/n)"
    case $response in
    read -r response
    case $response in
    [yY])
    hash tmutil &> /dev/null && sudo tmutil disablelocal
    break;;
    @@ -573,7 +582,8 @@ else

    echo ""
    echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)"
    case $response in
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    break;;
    @@ -582,7 +592,8 @@ else

    echo ""
    echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)"
    case $response in
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
    break;;
    @@ -591,7 +602,8 @@ else

    echo ""
    echo "Disable continuous spell checking in Messages.app? (y/n)"
    case $response in
    read -r response
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    break;;
    @@ -677,4 +689,4 @@ else
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
    fi
    fi
  7. Brandon Brown revised this gist Oct 21, 2014. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -109,7 +109,6 @@ else
    *) break;;
    esac


    echo ""
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
    @@ -162,6 +161,17 @@ else
    *) break;;
    esac

    echo ""
    echo "Add ability to toggle between Light and Dark mode in Yosemite using ctrl+opt+cmd+t? (y/n)"
    # http://www.reddit.com/r/apple/comments/2jr6s2/1010_i_found_a_way_to_dynamically_switch_between/
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true
    break;;
    *) break;;
    esac


    ###############################################################################
    # General Power and Performance modifications
  8. Brandon Brown revised this gist Oct 20, 2014. 1 changed file with 539 additions and 373 deletions.
    912 changes: 539 additions & 373 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -26,479 +26,645 @@ cecho() {
    return
    }

    # Ask for the administrator password upfront
    sudo -v

    # Keep-alive: update existing `sudo` time stamp until script has finished
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
    # Set continue to false by default
    CONTINUE=false

    echo ""
    cecho "##############################################" $red
    cecho "# CAUTION: DO NOT BLINDLY RUN THIS SCRIPT" $red
    cecho "# YOU WILL PROBABLY REGRET IT..." $red
    cecho "#############################################" $red
    cecho "###############################################" $red
    cecho "# DO NOT RUN THIS SCRIPT BLINDLY #" $red
    cecho "# YOU'LL PROBABLY REGRET IT... #" $red
    cecho "# #" $red
    cecho "# READ IT THOROUGHLY #" $red
    cecho "# AND EDIT TO SUIT YOUR NEEDS #" $red
    cecho "###############################################" $red
    echo ""


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

    echo ""
    echo "Setting your computer name (as done via System Preferences → Sharing)"
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME
    cecho "Have you read through the script you're about to run and " $red
    cecho "understood that it will make changes to your computer? (y/n)" $red
    read -r response
    case $response in
    [yY]) CONTINUE=true
    break;;
    *) break;;
    esac

    echo ""
    echo "Hiding the Time Machine, Volume, User, and Bluetooth icons"
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu"
    done
    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"
    if ! $CONTINUE; then
    # Check if we're continuing and output a message if not
    cecho "Please go read the script, it only takes a few minutes" $red
    else
    # Here we go.. ask for the administrator password upfront and run a
    # keep-alive to update existing `sudo` time stamp until script has finished
    sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    echo "Hide the Spotlight icon?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    ###############################################################################
    # General UI/UX
    ###############################################################################

    echo ""
    echo "Would you like to set your computer name (as done via System Preferences >> Sharing)? (y/n)"
    read -r response
    case $response in
    [yY])
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME
    break;;
    No ) break;;
    *) break;;
    esac
    done

    echo ""
    echo "Disabling OS X Gate Keeper"
    echo "(You'll be able to install any app you want from here on, not just Mac App Store apps)"
    sudo spctl --master-disable
    sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    echo ""
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
    echo ""
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons? (y/n)"
    read -r response
    case $response in
    [yY])
    # Get the system Hardware UUID and use it for the next menubar stuff
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu"
    done

    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"
    break;;
    *) break;;
    esac

    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
    echo ""
    echo "Hide the Spotlight icon? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    break;;
    *) break;;
    esac

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

    echo ""
    echo "Disabling system-wide resume"
    defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
    echo ""
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Disabling automatic termination of inactive apps"
    defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

    echo ""
    echo "Saving to disk (not to iCloud) by default"
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

    echo ""
    echo "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
    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

    echo ""
    echo "Never go into computer sleep mode"
    systemsetup -setcomputersleep Off > /dev/null
    echo ""
    echo "Save to disk, rather than iCloud, by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
    echo ""
    echo "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

    echo ""
    echo "Remove duplicates in the “Open With” menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    echo ""
    echo "Disable smart quotes and smart dashes as they're annoying when typing code"
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
    echo ""
    echo "Removing duplicates in the 'Open With' menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

    echo ""
    echo "Disable smart quotes and smart dashes? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
    break;;
    *) break;;
    esac

    ###############################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
    ###############################################################################
    # General Power and Performance modifications
    ###############################################################################

    echo ""
    echo "Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
    echo ""
    echo "Disable hibernation? (speeds up entering sleep mode) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a hibernatemode 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Disabling press-and-hold for keys in favor of a key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
    echo ""
    echo "Remove the sleep image file to save disk space? (y/n)"
    echo "(If you're on a <128GB SSD, this helps but can have adverse affects on performance. You've been warned.)"
    read -r response
    case $response in
    [yY])
    sudo rm /Private/var/vm/sleepimage
    echo "Creating a zero-byte file instead"
    sudo touch /Private/var/vm/sleepimage
    echo "and make sure it can't be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage
    break;;
    *) break;;
    esac

    echo ""
    echo "Setting a blazingly fast keyboard repeat rate (ain't nobody got time fo special chars while coding!)"
    defaults write NSGlobalDomain KeyRepeat -int 0
    echo ""
    echo "Disable the sudden motion sensor? (it's not useful for SSDs/current MacBooks) (y/n)"
    read -r response
    case $response in
    [yY])
    sudo pmset -a sms 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Disabling auto-correct"
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
    echo ""
    echo "Disable system-wide resume? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5
    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300
    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

    ###############################################################################
    # Screen
    ###############################################################################

    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0
    ################################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi
    echo "Enabling full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

    echo ""
    echo "Disabling press-and-hold for special keys in favor of key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2
    echo ""
    echo "Setting a blazingly fast keyboard repeat rate"
    defaults write NSGlobalDomain KeyRepeat -int 0

    echo ""
    echo "Enabling HiDPI display modes (requires restart)"
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
    echo ""
    echo "Disable auto-correct? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
    break;;
    *) break;;
    esac

    ###############################################################################
    # Finder
    ###############################################################################
    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5

    echo ""
    echo "Showing icons for hard drives, servers, and removable media on the desktop"
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

    echo ""
    echo "Show hidden files in Finder by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    No ) break;;
    echo ""
    echo "Disable display from automatically adjusting brightness"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false
    break;;
    *) break;;
    esac
    done

    echo ""
    echo "Show dotfiles in Finder by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    No ) break;;
    echo ""
    echo "Disable keyboard from automatically adjusting backlight brightness in low light? (y/n)"
    read -r response
    case $response in
    [yY])
    sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Keyboard Enabled" -bool false
    break;;
    *) break;;
    esac
    done

    echo ""
    echo "Showing all filename extensions in Finder by default"
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true

    echo ""
    echo "Showing status bar in Finder by default"
    defaults write com.apple.finder ShowStatusBar -bool true

    echo ""
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Displaying full POSIX path as Finder window title"
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    ###############################################################################
    # Screen
    ###############################################################################

    echo ""
    echo "Disabling the warning when changing a file extension"
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0

    echo ""
    echo "Use column view in all Finder windows by default"
    defaults write com.apple.finder FXPreferredViewStyle Clmv
    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi

    echo ""
    echo "Avoiding the creation of .DS_Store files on network volumes"
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi

    echo ""
    echo "Disabling 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
    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

    echo ""
    echo "Enabling 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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    echo ""
    echo "Enabling HiDPI display modes (requires restart)"
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

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

    ###############################################################################
    # Dock & Mission Control
    ###############################################################################
    echo ""
    echo "Show icons for hard drives, servers, and removable media on the desktop? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
    break;;
    *) break;;
    esac

    # Wipe all (default) app icons from the Dock
    # This is only really useful when setting up a new Mac, or if you don't use
    # the Dock to launch apps.
    #defaults write com.apple.dock persistent-apps -array
    echo ""
    echo "Show hidden files in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36
    echo ""
    echo "Show dotfiles in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    *) break;;
    esac

    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true
    echo ""
    echo "Show all filename extensions in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Setting Dock to auto-hide and removing the auto-hiding delay"
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0
    echo ""
    echo "Show status bar in Finder by default? (y/n)"
    read -r response
    case $response in
    [yY])
    defaults write com.apple.finder ShowStatusBar -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Display full POSIX path as Finder window title? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    break;;
    *) break;;
    esac

    ###############################################################################
    # Safari & WebKit
    ###############################################################################
    echo ""
    echo "Disable the warning when changing a file extension? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false
    echo ""
    echo "Use column view in all Finder windows by default? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.finder FXPreferredViewStyle Clmv
    break;;
    *) break;;
    esac

    echo ""
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false
    echo ""
    echo "Avoid creation of .DS_Store files on network volumes? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
    echo ""
    echo "Disable disk image verification? (y/n)"
    case $response in
    [yY])
    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
    break;;
    *) break;;
    esac

    echo ""
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
    echo ""
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
    echo ""
    echo "Enabling 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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist


    ###############################################################################
    # Dock & Mission Control
    ###############################################################################

    echo "Wipe all (default) app icons from the Dock? (y/n)"
    echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)"
    case $response in
    [yY])
    defaults write com.apple.dock persistent-apps -array
    break;;
    *) break;;
    esac

    echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"
    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36

    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true

    echo ""
    echo "Enabling 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
    echo ""
    echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0
    break;;
    *) break;;
    esac

    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

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

    ###############################################################################
    # Mail
    ###############################################################################
    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false

    echo ""
    echo "Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    echo ""
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false

    echo ""
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    ###############################################################################
    # Terminal
    ###############################################################################
    echo ""
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
    echo ""
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

    echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    ###############################################################################
    # Time Machine
    ###############################################################################
    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

    echo ""
    echo "Preventing Time Machine from prompting to use new hard drives as backup volume"
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    echo ""
    echo "Enabling 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

    echo ""
    echo "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal
    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true


    ###############################################################################
    # Messages #
    ###############################################################################
    ###############################################################################
    # Mail
    ###############################################################################

    echo ""
    echo "Disable automatic emoji substitution (i.e. use plain text smileys)"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    echo ""
    echo "Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    echo ""
    echo "Disable smart quotes as it's annoying for messages that contain code"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false

    echo ""
    echo "Disable continuous spell checking"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    ###############################################################################
    # Terminal
    ###############################################################################

    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"

    ###############################################################################
    # Transmission.app #
    ###############################################################################

    echo ""
    echo "Use `~/Downloads/Incomplete` to store incomplete downloads"
    defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"
    ###############################################################################
    # Time Machine
    ###############################################################################

    echo ""
    echo "Don't prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false
    echo ""
    echo "Prevent Time Machine from prompting to use new hard drives as backup volume? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    break;;
    *) break;;
    esac

    echo ""
    echo "Trash original torrent files"
    defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
    echo ""
    echo "Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs) (y/n)"
    case $response in
    [yY])
    hash tmutil &> /dev/null && sudo tmutil disablelocal
    break;;
    *) break;;
    esac

    echo ""
    echo "Hide the donate message"
    defaults write org.m0k.transmission WarningDonate -bool false

    echo ""
    echo "Hide the legal disclaimer"
    defaults write org.m0k.transmission WarningLegal -bool false
    ###############################################################################
    # Messages #
    ###############################################################################

    echo ""
    echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)"
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    break;;
    *) break;;
    esac

    ###############################################################################
    # Personal Additions
    ###############################################################################
    echo ""
    echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)"
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Disable hibernation (speeds up entering sleep mode)"
    sudo pmset -a hibernatemode 0
    echo ""
    echo "Disable continuous spell checking in Messages.app? (y/n)"
    case $response in
    [yY])
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    break;;
    *) break;;
    esac

    echo ""
    echo "Remove the sleep image file to save disk space"
    sudo rm /Private/var/vm/sleepimage
    echo "creating a zero-byte file instead"
    sudo touch /Private/var/vm/sleepimage
    echo "and make sure it can't be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage

    echo ""
    echo "Disable the sudden motion sensor as it's not useful for SSDs"
    sudo pmset -a sms 0
    ###############################################################################
    # Transmission.app #
    ###############################################################################

    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Disable annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
    echo ""
    echo "Do you use Transmission for torrenting? (y/n)"
    read -r response
    case $response in
    [yY])
    echo ""
    echo "Use `~/Downloads/Incomplete` to store incomplete downloads"
    defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    mkdir -p ~/Downloads/Incomplete
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"

    echo ""
    echo "Don't prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false

    echo ""
    echo "Trash original torrent files"
    defaults write org.m0k.transmission DeleteOriginalTorrent -bool true

    echo ""
    echo "Hide the donate message"
    defaults write org.m0k.transmission WarningDonate -bool false

    echo ""
    echo "Hide the legal disclaimer"
    defaults write org.m0k.transmission WarningLegal -bool false
    break;;
    *) break;;
    esac


    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice and is it installed?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo ""
    echo "Linking Sublime Text command line"
    ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    echo ""
    echo "Removing Mission Control as it interferes with Sublime Text keyboard shortcut for selecting multiple lines"
    defaults write com.apple.dock mcx-expose-disabled -bool TRUE
    break;;
    No ) break;;
    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice, and is it installed?"
    read -r response
    case $response in
    [yY])
    # Installing from homebrew cask does the following for you!
    # echo ""
    # echo "Linking Sublime Text for command line usage as subl"
    # ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    break;;
    *) break;;
    esac
    done


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

    echo ""
    cecho "Done!" $white
    echo ""
    echo ""
    cecho "###############################################################################" $white
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect." $white
    cecho "Killing some open applications in order to take effect." $white
    echo ""
    echo ""
    cecho "Done!" $cyan
    echo ""
    echo ""
    cecho "################################################################################" $white
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect." $red
    cecho "Killing some open applications in order to take effect." $red
    echo ""

    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
    fi
  9. Brandon Brown revised this gist Oct 16, 2014. No changes.
  10. Brandon Brown revised this gist Oct 16, 2014. No changes.
  11. Brandon Brown revised this gist Oct 14, 2014. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -33,12 +33,10 @@ sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    cecho "##############################################" $white
    cecho "# This script will make your  Mac awesome." $white
    cecho "# Follow the prompts and you'll be fine." $white
    cecho "#" $white
    cecho "# ~ Happy Hacking ~" $white
    cecho "#############################################" $white
    cecho "##############################################" $red
    cecho "# CAUTION: DO NOT BLINDLY RUN THIS SCRIPT" $red
    cecho "# YOU WILL PROBABLY REGRET IT..." $red
    cecho "#############################################" $red
    echo ""


  12. Brandon Brown revised this gist Oct 2, 2014. 1 changed file with 27 additions and 24 deletions.
    51 changes: 27 additions & 24 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    cecho "##############################################" $white
    cecho "# This script will make your Mac awesome." $white
    cecho "# This script will make your  Mac awesome." $white
    cecho "# Follow the prompts and you'll be fine." $white
    cecho "#" $white
    cecho "# ~ Happy Hacking ~" $white
    @@ -47,7 +47,7 @@ echo ""
    ###############################################################################

    echo ""
    echo "Setting your computer name (as done via System Preferences Sharing)"
    echo "Setting your computer name (as done via System Preferences → Sharing)"
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    @@ -56,7 +56,7 @@ sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME

    echo ""
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons"
    echo "Hiding the Time Machine, Volume, User, and Bluetooth icons"
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    @@ -69,7 +69,15 @@ defaults write com.apple.systemuiserver menuExtras -array \
    "/System/Library/CoreServices/Menu Extras/Battery.menu" \
    "/System/Library/CoreServices/Menu Extras/Clock.menu"

    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    echo ""
    echo "Hide the Spotlight icon?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    break;;
    No ) break;;
    esac
    done

    echo ""
    echo "Disabling OS X Gate Keeper"
    @@ -122,11 +130,11 @@ echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    echo ""
    echo "Remove duplicates in the “Open With” menu"
    echo "Remove duplicates in the “Open With” menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

    echo ""
    echo "Disable smart quotes and smart dashes as theyre annoying when typing code"
    echo "Disable smart quotes and smart dashes as they're annoying when typing code"
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

    @@ -207,7 +215,7 @@ echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

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

    ###############################################################################
    @@ -284,7 +292,7 @@ echo "Enabling snap-to-grid for icons on the desktop and in other icon views"
    ###############################################################################

    # Wipe all (default) app icons from the Dock
    # This is only really useful when setting up a new Mac, or if you dont use
    # This is only really useful when setting up a new Mac, or if you don't use
    # the Dock to launch apps.
    #defaults write com.apple.dock persistent-apps -array

    @@ -309,27 +317,27 @@ defaults write com.apple.dock autohide-time-modifier -float 0
    ###############################################################################

    echo ""
    echo "Hiding Safaris bookmarks bar by default"
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false

    echo ""
    echo "Hiding Safaris sidebar in Top Sites"
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false

    echo ""
    echo "Disabling Safaris thumbnail cache for History and Top Sites"
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    echo ""
    echo "Enabling Safaris debug menu"
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Making Safaris search banners default to Contains instead of Starts With"
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

    echo ""
    echo "Removing useless icons from Safaris bookmarks bar"
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    echo ""
    @@ -389,7 +397,7 @@ echo "Disable automatic emoji substitution (i.e. use plain text smileys)"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false

    echo ""
    echo "Disable smart quotes as its annoying for messages that contain code"
    echo "Disable smart quotes as it's annoying for messages that contain code"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false

    echo ""
    @@ -407,7 +415,7 @@ defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"

    echo ""
    echo "Dont prompt for confirmation before downloading"
    echo "Don't prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false

    echo ""
    @@ -434,25 +442,20 @@ sudo pmset -a hibernatemode 0
    echo ""
    echo "Remove the sleep image file to save disk space"
    sudo rm /Private/var/vm/sleepimage
    echo "Creating a zero-byte file instead"
    echo "creating a zero-byte file instead"
    sudo touch /Private/var/vm/sleepimage
    echo "and make sure it cant be rewritten"
    echo "and make sure it can't be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage

    echo ""
    echo "Disable the sudden motion sensor as its not useful for SSDs"
    echo "Disable the sudden motion sensor as it's not useful for SSDs"
    sudo pmset -a sms 0

    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo ""
    echo "Disable annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
  13. Brandon Brown revised this gist Aug 13, 2014. 1 changed file with 106 additions and 38 deletions.
    144 changes: 106 additions & 38 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -33,12 +33,12 @@ sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking ~"
    echo "#############################################"
    cecho "##############################################" $white
    cecho "# This script will make your  Mac awesome." $white
    cecho "# Follow the prompts and you'll be fine." $white
    cecho "#" $white
    cecho "# ~ Happy Hacking ~" $white
    cecho "#############################################" $white
    echo ""


    @@ -56,8 +56,19 @@ sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME

    echo ""
    echo "Hiding the useless menubar 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"
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons"
    for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    defaults write "${domain}" dontAutoLoad -array \
    "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
    "/System/Library/CoreServices/Menu Extras/Volume.menu" \
    "/System/Library/CoreServices/Menu Extras/User.menu"
    done
    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"

    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

    echo ""
    @@ -68,12 +79,18 @@ sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    echo ""
    echo "Increasing the window resize speed for Cocoa applications whether you like it or not"
    echo "Increasing the window resize speed for Cocoa applications"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    @@ -104,6 +121,16 @@ echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    echo ""
    echo "Remove duplicates in the “Open With” menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

    echo ""
    echo "Disable smart quotes and smart dashes as they’re annoying when typing code"
    defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
    defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false


    ###############################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################
    @@ -117,7 +144,7 @@ echo "Enabling full keyboard access for all controls (e.g. enable Tab in modal d
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

    echo ""
    echo "Disabling press-and-hold for keys in favor of key repeat "
    echo "Disabling press-and-hold for keys in favor of a key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

    echo ""
    @@ -175,9 +202,14 @@ else
    fi


    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

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

    ###############################################################################
    # Finder
    ###############################################################################
    @@ -276,6 +308,14 @@ defaults write com.apple.dock autohide-time-modifier -float 0
    # Safari & WebKit
    ###############################################################################

    echo ""
    echo "Hiding Safari’s bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false

    echo ""
    echo "Hiding Safari’s sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false

    echo ""
    echo "Disabling Safari’s thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
    @@ -292,6 +332,10 @@ echo ""
    echo "Removing useless icons from Safari’s bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    echo ""
    echo "Allow hitting the Backspace key to go to the previous page in history"
    defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

    echo ""
    echo "Enabling the Develop menu and the Web Inspector in Safari"
    defaults write com.apple.Safari IncludeDevelopMenu -bool true
    @@ -336,6 +380,49 @@ echo "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal


    ###############################################################################
    # Messages #
    ###############################################################################

    echo ""
    echo "Disable automatic emoji substitution (i.e. use plain text smileys)"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false

    echo ""
    echo "Disable smart quotes as it’s annoying for messages that contain code"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false

    echo ""
    echo "Disable continuous spell checking"
    defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false


    ###############################################################################
    # Transmission.app #
    ###############################################################################

    echo ""
    echo "Use `~/Downloads/Incomplete` to store incomplete downloads"
    defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
    defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"

    echo ""
    echo "Don’t prompt for confirmation before downloading"
    defaults write org.m0k.transmission DownloadAsk -bool false

    echo ""
    echo "Trash original torrent files"
    defaults write org.m0k.transmission DeleteOriginalTorrent -bool true

    echo ""
    echo "Hide the donate message"
    defaults write org.m0k.transmission WarningDonate -bool false

    echo ""
    echo "Hide the legal disclaimer"
    defaults write org.m0k.transmission WarningLegal -bool false


    ###############################################################################
    # Personal Additions
    ###############################################################################
    @@ -393,43 +480,24 @@ select yn in "Yes" "No"; do
    done


    ###############################################################################
    # Git
    ###############################################################################
    echo ""
    echo "Create a nicely formatted git log command accessible via 'git lg'?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo "Creating nice git log command"
    git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
    break;;
    No ) break;;
    esac
    done

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

    echo ""
    echo "Done!"
    cecho "Done!" $white
    echo ""
    echo ""
    echo "###############################################################################"
    cecho "###############################################################################" $white
    echo ""
    echo ""
    echo "Note that some of these changes require a logout/restart to take effect."
    echo "Killing some open applications in order to take effect."
    cecho "Note that some of these changes require a logout/restart to take effect." $white
    cecho "Killing some open applications in order to take effect." $white
    echo ""

    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in Finder Dock Mail Safari iTunes iCal Address\ Book SystemUIServer; do
    killall "$app" > /dev/null 2>&1
    done


    # Ask for the administrator password upfront
    sudo -v

    # Keep-alive: update existing `sudo` time stamp until script has finished
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
    "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
    "Terminal" "Transmission"; do
    killall "${app}" > /dev/null 2>&1
    done
  14. Brandon Brown revised this gist Aug 13, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -366,6 +366,10 @@ echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo ""
    echo "Disable annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false


    ###############################################################################
    # Sublime Text
  15. Brandon Brown revised this gist Jul 24, 2014. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -339,11 +339,23 @@ hash tmutil &> /dev/null && sudo tmutil disablelocal
    ###############################################################################
    # Personal Additions
    ###############################################################################

    echo ""
    echo "Deleting space hogging sleep image and disabling"
    sudo rm /private/var/vm/sleepimage
    echo "Disable hibernation (speeds up entering sleep mode)"
    sudo pmset -a hibernatemode 0

    echo ""
    echo "Remove the sleep image file to save disk space"
    sudo rm /Private/var/vm/sleepimage
    echo "Creating a zero-byte file instead…"
    sudo touch /Private/var/vm/sleepimage
    echo "…and make sure it can’t be rewritten"
    sudo chflags uchg /Private/var/vm/sleepimage

    echo ""
    echo "Disable the sudden motion sensor as it’s not useful for SSDs"
    sudo pmset -a sms 0

    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
  16. Brandon Brown revised this gist Jun 30, 2014. 1 changed file with 26 additions and 51 deletions.
    77 changes: 26 additions & 51 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -26,12 +26,18 @@ cecho() {
    return
    }

    # Ask for the administrator password upfront
    sudo -v

    # Keep-alive: update existing `sudo` time stamp until script has finished
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "# ~ Happy Hacking ~"
    echo "#############################################"
    echo ""

    @@ -50,14 +56,16 @@ sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME

    echo ""
    echo "Hiding the useless menubar icons?"
    echo "Hiding the useless menubar 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"
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

    echo ""
    echo "Disabling OS X Gate Keeper"
    echo "(You'll be able to install any app you want from here on, not just Mac App Store apps)"
    sudo spctl --master-disable
    sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    echo ""
    echo "Increasing the window resize speed for Cocoa applications whether you like it or not"
    @@ -67,10 +75,6 @@ echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

    echo ""
    echo "Disabling the 'Are you sure you want to open this application from the Internet?' dialog"
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    @@ -183,7 +187,7 @@ echo "Showing icons for hard drives, servers, and removable media on the desktop
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true

    echo ""
    echo "Finder: show hidden files by default?"
    echo "Show hidden files in Finder by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.Finder AppleShowAllFiles -bool true
    @@ -193,7 +197,7 @@ select yn in "Yes" "No"; do
    done

    echo ""
    echo "Finder: show dotfiles?"
    echo "Show dotfiles in Finder by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    @@ -203,23 +207,19 @@ select yn in "Yes" "No"; do
    done

    echo ""
    echo "Finder: showing all filename extensions"
    echo "Showing all filename extensions in Finder by default"
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true

    echo ""
    echo "Finder: showing status bar"
    echo "Showing status bar in Finder by default"
    defaults write com.apple.finder ShowStatusBar -bool true

    echo ""
    echo "Finder: show path bar"
    defaults write com.apple.finder ShowPathbar -bool true

    echo ""
    echo "Finder: allowing text selection in Quick Look/Preview"
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Displaying full POSIX path as Finder window title?"
    echo "Displaying full POSIX path as Finder window title"
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

    echo ""
    @@ -228,11 +228,10 @@ defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

    echo ""
    echo "Use column view in all Finder windows by default"
    # defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
    defaults write com.apple.finder FXPreferredViewStyle Clmv

    echo ""
    echo "Avoiding creating stupid .DS_Store files on network volumes"
    echo "Avoiding the creation of .DS_Store files on network volumes"
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

    echo ""
    @@ -242,15 +241,11 @@ defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
    defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true

    echo ""
    echo "Enable snap-to-grid for icons on the desktop and in other icon views?"
    echo "Enabling 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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

    echo ""
    echo "Setting Trash to empty securely by default"
    defaults write com.apple.finder EmptyTrashSecurely -bool true


    ###############################################################################
    # Dock & Mission Control
    @@ -276,14 +271,6 @@ defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0

    echo ""
    echo "Setting Dock to 2D mode"
    defaults write com.apple.dock no-glass -boolean YES

    echo ""
    echo "Pinning the Dock to the left side of the screen for most efficient use of screen realestate"
    #defaults write com.apple.dock pinning -string "end"


    ###############################################################################
    # Safari & WebKit
    @@ -317,21 +304,13 @@ defaults write NSGlobalDomain WebKitDeveloperExtras -bool true


    ###############################################################################
    # Address Book and iTunes
    # Mail
    ###############################################################################

    echo ""
    echo "Enabling iTunes track notifications in the Dock"
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    echo "Set email addresses top copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app?"
    echo "Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    echo ""
    echo "Enabling the debug menu in Disk Utility"
    defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true


    ###############################################################################
    # Terminal
    @@ -362,23 +341,19 @@ hash tmutil &> /dev/null && sudo tmutil disablelocal
    ###############################################################################
    echo ""
    echo "Deleting space hogging sleep image and disabling"
    sudo rm /private/var/vm/sleepimage && sudo pmset -a hibernatemode 0
    sudo rm /private/var/vm/sleepimage
    sudo pmset -a hibernatemode 0

    echo ""
    echo "Speed up wake from sleep to 24 hours from an hour"
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    pmset -a standbydelay 86400
    sudo pmset -a standbydelay 86400

    echo ""
    echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo ""
    echo "Disabling OS X logging of downloaded files"
    echo "For more info visit http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/"
    defaults write com.apple.LaunchServices LSQuarantine -bool NO


    ###############################################################################
    # Sublime Text
    @@ -410,8 +385,8 @@ echo "Create a nicely formatted git log command accessible via 'git lg'?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo "Creating nice git log command"
    git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
    break;;
    git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
    break;;
    No ) break;;
    esac
    done
  17. Brandon Brown revised this gist Jun 11, 2014. No changes.
  18. Brandon Brown revised this gist Jun 11, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -126,7 +126,7 @@ defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.sca ng 2
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5

    echo ""
    @@ -362,8 +362,7 @@ hash tmutil &> /dev/null && sudo tmutil disablelocal
    ###############################################################################
    echo ""
    echo "Deleting space hogging sleep image and disabling"
    sudo rm /private/var/vm/sleepimage
    sudo pmset -a hibernatemode 0
    sudo rm /private/var/vm/sleepimage && sudo pmset -a hibernatemode 0

    echo ""
    echo "Speed up wake from sleep to 24 hours from an hour"
  19. Brandon Brown revised this gist Jun 11, 2014. 1 changed file with 402 additions and 416 deletions.
    818 changes: 402 additions & 416 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -26,434 +26,420 @@ cecho() {
    return
    }


    doOSXStuff() {
    ###############################################################################
    # General UI/UX
    ###############################################################################

    echo ""
    echo "Setting your computer name (as done via System Preferences → Sharing)"
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME

    echo ""
    echo "Hiding the useless menubar 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"
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

    echo ""
    echo "Disabling OS X Gate Keeper"
    echo "(You'll be able to install any app you want from here on, not just Mac App Store apps)"
    sudo spctl --master-disable

    echo ""
    echo "Increasing the window resize speed for Cocoa applications whether you like it or not"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

    echo ""
    echo "Disabling the 'Are you sure you want to open this application from the Internet?' dialog"
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

    echo ""
    echo "Disabling system-wide resume"
    defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

    echo ""
    echo "Disabling automatic termination of inactive apps"
    defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true

    echo ""
    echo "Saving to disk (not to iCloud) by default"
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

    echo ""
    echo "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

    echo ""
    echo "Never go into computer sleep mode"
    systemsetup -setcomputersleep Off > /dev/null

    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    ###############################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

    echo ""
    echo "Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

    echo ""
    echo "Disabling press-and-hold for keys in favor of key repeat "
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

    echo ""
    echo "Setting a blazingly fast keyboard repeat rate (ain't nobody got time fo special chars while coding!)"
    defaults write NSGlobalDomain KeyRepeat -int 0

    echo ""
    echo "Disabling auto-correct"
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.sca ng 2
    defaults write -g com.apple.mouse.scaling 2.5

    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

    ###############################################################################
    # Screen
    ###############################################################################

    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi

    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi


    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

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

    echo ""
    echo "Showing icons for hard drives, servers, and removable media on the desktop"
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true

    echo ""
    echo "Finder: show hidden files by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    No ) break;;
    esac
    done

    echo ""
    echo "Finder: show dotfiles?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    No ) break;;
    esac
    done

    echo ""
    echo "Finder: showing all filename extensions"
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true

    echo ""
    echo "Finder: showing status bar"
    defaults write com.apple.finder ShowStatusBar -bool true

    echo ""
    echo "Finder: show path bar"
    defaults write com.apple.finder ShowPathbar -bool true

    echo ""
    echo "Finder: allowing text selection in Quick Look/Preview"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Displaying full POSIX path as Finder window title?"
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

    echo ""
    echo "Disabling the warning when changing a file extension"
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

    echo ""
    echo "Use column view in all Finder windows by default"
    # defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
    defaults write com.apple.finder FXPreferredViewStyle Clmv

    echo ""
    echo "Avoiding creating stupid .DS_Store files on network volumes"
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

    echo ""
    echo "Disabling 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

    echo ""
    echo "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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

    echo ""
    echo "Setting Trash to empty securely by default"
    defaults write com.apple.finder EmptyTrashSecurely -bool true


    ###############################################################################
    # Dock & Mission Control
    ###############################################################################

    # Wipe all (default) app icons from the Dock
    # This is only really useful when setting up a new Mac, or if you don’t use
    # the Dock to launch apps.
    #defaults write com.apple.dock persistent-apps -array

    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36

    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true

    echo ""
    echo "Setting Dock to auto-hide and removing the auto-hiding delay"
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0

    echo ""
    echo "Setting Dock to 2D mode"
    defaults write com.apple.dock no-glass -boolean YES

    echo ""
    echo "Pinning the Dock to the left side of the screen for most efficient use of screen realestate"
    #defaults write com.apple.dock pinning -string "end"


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

    echo ""
    echo "Disabling Safari’s thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    echo ""
    echo "Enabling Safari’s debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Making Safari’s search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

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

    echo ""
    echo "Enabling 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

    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true


    ###############################################################################
    # Address Book and iTunes
    ###############################################################################

    echo ""
    echo "Enabling iTunes track notifications in the Dock"
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    echo "Set email addresses top copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app?"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    echo ""
    echo "Enabling the debug menu in Disk Utility"
    defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true


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

    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"


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

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

    echo ""
    echo "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal


    ###############################################################################
    # Personal Additions
    ###############################################################################
    echo ""
    echo "Deleting space hogging sleep image and disabling"
    sudo rm /private/var/vm/sleepimage
    sudo pmset -a hibernatemode 0

    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "#############################################"
    echo ""


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

    echo ""
    echo "Setting your computer name (as done via System Preferences → Sharing)"
    echo "What would you like it to be?"
    read COMPUTER_NAME
    sudo scutil --set ComputerName $COMPUTER_NAME
    sudo scutil --set HostName $COMPUTER_NAME
    sudo scutil --set LocalHostName $COMPUTER_NAME
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME

    echo ""
    echo "Hiding the useless menubar 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"
    sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

    echo ""
    echo "Disabling OS X Gate Keeper"
    echo "(You'll be able to install any app you want from here on, not just Mac App Store apps)"
    sudo spctl --master-disable

    echo ""
    echo "Increasing the window resize speed for Cocoa applications whether you like it or not"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

    echo ""
    echo "Disabling the 'Are you sure you want to open this application from the Internet?' dialog"
    defaults write com.apple.LaunchServices LSQuarantine -bool false

    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

    echo ""
    echo "Disabling system-wide resume"
    defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

    echo ""
    echo "Disabling automatic termination of inactive apps"
    defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true

    echo ""
    echo "Saving to disk (not to iCloud) by default"
    defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

    echo ""
    echo "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

    echo ""
    echo "Never go into computer sleep mode"
    systemsetup -setcomputersleep Off > /dev/null

    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

    ###############################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################

    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

    echo ""
    echo "Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

    echo ""
    echo "Disabling press-and-hold for keys in favor of key repeat "
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

    echo ""
    echo "Setting a blazingly fast keyboard repeat rate (ain't nobody got time fo special chars while coding!)"
    defaults write NSGlobalDomain KeyRepeat -int 0

    echo ""
    echo "Disabling auto-correct"
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.sca ng 2
    defaults write -g com.apple.mouse.scaling 2.5

    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

    ###############################################################################
    # Screen
    ###############################################################################

    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0

    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    read screenshot_location
    if [ -z "$1" ]
    then
    echo ""
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Speed up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    pmset -a standbydelay 86400
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi

    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
    echo ""
    echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Disabling OS X logging of downloaded files"
    echo "For more info visit http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/"
    defaults write com.apple.LaunchServices LSQuarantine -bool NO

    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi

    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice and is it installed?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo ""
    echo "Linking Sublime Text command line"
    ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    echo ""
    echo "Removing Mission Control as it interferes with Sublime Text keyboard shortcut for selecting multiple lines"
    defaults write com.apple.dock mcx-expose-disabled -bool TRUE
    break;;
    No ) break;;
    esac
    done


    ###############################################################################
    # Git
    ###############################################################################
    echo ""
    echo "Create a nicely formatted git log command accessible via 'git lg'?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo "Creating nice git log command"
    git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
    break;;
    No ) break;;
    esac
    done

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

    echo ""
    echo "Done!"
    echo ""
    echo ""
    echo "###############################################################################"
    echo ""
    echo ""
    echo "Note that some of these changes require a logout/restart to take effect."
    echo "Killing some open applications in order to take effect."
    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2

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

    echo ""
    echo "Showing icons for hard drives, servers, and removable media on the desktop"
    defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true

    echo ""
    echo "Finder: show hidden files by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.Finder AppleShowAllFiles -bool true
    break;;
    No ) break;;
    esac
    done

    echo ""
    echo "Finder: show dotfiles?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    break;;
    No ) break;;
    esac
    done

    echo ""
    echo "Finder: showing all filename extensions"
    defaults write NSGlobalDomain AppleShowAllExtensions -bool true

    echo ""
    echo "Finder: showing status bar"
    defaults write com.apple.finder ShowStatusBar -bool true

    echo ""
    echo "Finder: show path bar"
    defaults write com.apple.finder ShowPathbar -bool true

    echo ""
    echo "Finder: allowing text selection in Quick Look/Preview"
    defaults write com.apple.finder QLEnableTextSelection -bool true

    echo ""
    echo "Displaying full POSIX path as Finder window title?"
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

    echo ""
    echo "Disabling the warning when changing a file extension"
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

    echo ""
    echo "Use column view in all Finder windows by default"
    # defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
    defaults write com.apple.finder FXPreferredViewStyle Clmv

    echo ""
    echo "Avoiding creating stupid .DS_Store files on network volumes"
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

    echo ""
    echo "Disabling 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

    echo ""
    echo "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 :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

    echo ""
    echo "Setting Trash to empty securely by default"
    defaults write com.apple.finder EmptyTrashSecurely -bool true


    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in Finder Dock Mail Safari iTunes iCal Address\ Book SystemUIServer; do
    killall "$app" > /dev/null 2>&1
    done
    ###############################################################################
    # Dock & Mission Control
    ###############################################################################

    }
    # Wipe all (default) app icons from the Dock
    # This is only really useful when setting up a new Mac, or if you don’t use
    # the Dock to launch apps.
    #defaults write com.apple.dock persistent-apps -array

    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36

    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true

    echo ""
    echo "Setting Dock to auto-hide and removing the auto-hiding delay"
    defaults write com.apple.dock autohide -bool true
    defaults write com.apple.dock autohide-delay -float 0
    defaults write com.apple.dock autohide-time-modifier -float 0

    echo ""
    echo "Setting Dock to 2D mode"
    defaults write com.apple.dock no-glass -boolean YES

    echo ""
    echo "Pinning the Dock to the left side of the screen for most efficient use of screen realestate"
    #defaults write com.apple.dock pinning -string "end"


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

    echo ""
    echo "Disabling Safari’s thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

    echo ""
    echo "Enabling Safari’s debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    echo "Making Safari’s search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

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

    echo ""
    echo "Enabling 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

    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true


    ###############################################################################
    # Address Book and iTunes
    ###############################################################################

    echo ""
    echo "Enabling iTunes track notifications in the Dock"
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    echo "Set email addresses top copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app?"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    echo ""
    echo "Enabling the debug menu in Disk Utility"
    defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true


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

    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"


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

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

    echo ""
    echo "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal


    ###############################################################################
    # Personal Additions
    ###############################################################################
    echo ""
    echo "Deleting space hogging sleep image and disabling"
    sudo rm /private/var/vm/sleepimage
    sudo pmset -a hibernatemode 0

    echo ""
    echo "Speed up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    pmset -a standbydelay 86400

    echo ""
    echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo ""
    echo "Disabling OS X logging of downloaded files"
    echo "For more info visit http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/"
    defaults write com.apple.LaunchServices LSQuarantine -bool NO


    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice and is it installed?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo ""
    echo "Linking Sublime Text command line"
    ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    echo ""
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    echo ""
    echo "Removing Mission Control as it interferes with Sublime Text keyboard shortcut for selecting multiple lines"
    defaults write com.apple.dock mcx-expose-disabled -bool TRUE
    break;;
    No ) break;;
    esac
    done


    ###############################################################################
    # Git
    ###############################################################################
    echo ""
    echo "Create a nicely formatted git log command accessible via 'git lg'?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo "Creating nice git log command"
    git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
    break;;
    No ) break;;
    esac
    done

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

    echo ""
    echo "Done!"
    echo ""
    echo ""
    echo "###############################################################################"
    echo ""
    echo ""
    echo "Note that some of these changes require a logout/restart to take effect."
    echo "Killing some open applications in order to take effect."
    echo ""

    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in Finder Dock Mail Safari iTunes iCal Address\ Book SystemUIServer; do
    killall "$app" > /dev/null 2>&1
    done


    # Ask for the administrator password upfront
    sudo -v

    # Keep-alive: update existing `sudo` time stamp until script has finished
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    # Check platform
    if [[ "$(uname)" == "Darwin" ]]; then
    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "#############################################"
    echo ""

    doOSXStuff()
    elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
    echo "(ノ^_^)ノ Thank you for using a sane platform!"
    echo " Unfortunately, you'll need to run this script on a  Mac."
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
    fi
  20. Brandon Brown revised this gist May 15, 2014. No changes.
  21. Brandon Brown revised this gist May 15, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -220,7 +220,8 @@ doOSXStuff() {

    echo ""
    echo "Use column view in all Finder windows by default"
    defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
    # defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
    defaults write com.apple.finder FXPreferredViewStyle Clmv

    echo ""
    echo "Avoiding creating stupid .DS_Store files on network volumes"
  22. Brandon Brown revised this gist May 15, 2014. 1 changed file with 7 additions and 8 deletions.
    15 changes: 7 additions & 8 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -306,6 +306,7 @@ doOSXStuff() {
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true


    ###############################################################################
    # Address Book and iTunes
    ###############################################################################
    @@ -315,19 +316,14 @@ doOSXStuff() {
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    echo "Copy email addresses as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    break;;
    No ) break;;
    esac
    done
    echo "Set email addresses top copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app?"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

    echo ""
    echo "Enabling the debug menu in Disk Utility"
    defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true


    ###############################################################################
    # Terminal
    ###############################################################################
    @@ -338,6 +334,7 @@ doOSXStuff() {
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"


    ###############################################################################
    # Time Machine
    ###############################################################################
    @@ -350,6 +347,7 @@ doOSXStuff() {
    echo "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal


    ###############################################################################
    # Personal Additions
    ###############################################################################
    @@ -373,6 +371,7 @@ doOSXStuff() {
    echo "For more info visit http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/"
    defaults write com.apple.LaunchServices LSQuarantine -bool NO


    ###############################################################################
    # Sublime Text
    ###############################################################################
  23. Brandon Brown revised this gist May 15, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -374,10 +374,10 @@ doOSXStuff() {
    defaults write com.apple.LaunchServices LSQuarantine -bool NO

    ###############################################################################
    # Sublime Text - Needs to be ST3
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text as your editor of choice and is it installed?"
    echo "Do you use Sublime Text 3 as your editor of choice and is it installed?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo ""
  24. Brandon Brown revised this gist May 15, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -374,7 +374,7 @@ doOSXStuff() {
    defaults write com.apple.LaunchServices LSQuarantine -bool NO

    ###############################################################################
    # Sublime Text
    # Sublime Text - Needs to be ST3
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text as your editor of choice and is it installed?"
  25. Brandon Brown revised this gist May 15, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -452,7 +452,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
    doOSXStuff()
    elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
    echo "(ノ^_^)ノ Thank you for using a sane platform!"
    echo "Unfortunately, you'll need to run this script on a  Mac."
    echo " Unfortunately, you'll need to run this script on a  Mac."
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
  26. Brandon Brown revised this gist May 15, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -451,7 +451,8 @@ if [[ "$(uname)" == "Darwin" ]]; then

    doOSXStuff()
    elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
    echo "(ノ^_^)ノ Thank you for using a sane platform! Unfortunately, you'll need to run this script on a  Mac."
    echo "(ノ^_^)ノ Thank you for using a sane platform!"
    echo "Unfortunately, you'll need to run this script on a  Mac."
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
  27. Brandon Brown revised this gist May 15, 2014. 1 changed file with 10 additions and 9 deletions.
    19 changes: 10 additions & 9 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -28,14 +28,6 @@ cecho() {


    doOSXStuff() {
    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "#############################################"
    echo ""
    ###############################################################################
    # General UI/UX
    ###############################################################################
    @@ -448,9 +440,18 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    # Check platform
    if [[ "$(uname)" == "Darwin" ]]; then
    echo ""
    echo "##############################################"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "#############################################"
    echo ""

    doOSXStuff()
    elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
    echo "(ノ^_^)ノ Thank you for using a sane platform! Unfortunately, you'll need to run this script on a  Mac"
    echo "(ノ^_^)ノ Thank you for using a sane platform! Unfortunately, you'll need to run this script on a  Mac."
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
  28. Brandon Brown revised this gist May 15, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -448,7 +448,7 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    # Check platform
    if [[ "$(uname)" == "Darwin" ]]; then
    # run everything else
    doOSXStuff()
    elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
    echo "(ノ^_^)ノ Thank you for using a sane platform! Unfortunately, you'll need to run this script on a  Mac"
    else
  29. Brandon Brown revised this gist May 15, 2014. No changes.
  30. Brandon Brown revised this gist May 15, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -30,10 +30,10 @@ cecho() {
    doOSXStuff() {
    echo ""
    echo "##############################################"
    echo " This script will make your  Mac awesome."
    echo " Follow the prompts and you'll be fine."
    echo ""
    echo " ~ Happy Hacking! ~"
    echo "# This script will make your  Mac awesome."
    echo "# Follow the prompts and you'll be fine."
    echo "#"
    echo "# ~ Happy Hacking! ~"
    echo "#############################################"
    echo ""
    ###############################################################################