Skip to content

Instantly share code, notes, and snippets.

@jfchevrette
Forked from brandonb927/osx-for-hackers.sh
Last active August 29, 2015 14:07

Revisions

  1. 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
  2. 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
  3. 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/
  4. 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 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app?"
    echo "Setting email addresses to copy as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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
  5. Brandon Brown revised this gist Jun 11, 2014. No changes.
  6. 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"
  7. 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 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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
  8. Brandon Brown revised this gist May 15, 2014. No changes.
  9. 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"
  10. 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 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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
    ###############################################################################
  11. 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 ""
  12. 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?"
  13. 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 "(╯°□°)╯︵ ┻━┻"
  14. 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 "(╯°□°)╯︵ ┻━┻"
  15. 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 "(╯°□°)╯︵ ┻━┻"
  16. 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
  17. Brandon Brown revised this gist May 15, 2014. No changes.
  18. 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 ""
    ###############################################################################
  19. 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 ""
    ###############################################################################
  20. Brandon Brown revised this gist May 15, 2014. 1 changed file with 423 additions and 417 deletions.
    840 changes: 423 additions & 417 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -26,426 +26,432 @@ cecho() {
    return
    }


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

    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"

    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 "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 ""
    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 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
    # Do something under Mac OS X platform
    # run everything else
    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
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
    fi


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

    # 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 "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 ""
    # 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 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
  21. 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
    @@ -28,7 +28,7 @@ cecho() {

    # Check platform
    if [[ "$(uname)" == "Darwin" ]]; then
    # Do something under Mac OS X platform
    # Do something under Mac OS X platform
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
  22. 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
    @@ -27,7 +27,7 @@ cecho() {
    }

    # Check platform
    if [ "$(uname)" == "Darwin" ]; then
    if [[ "$(uname)" == "Darwin" ]]; then
    # Do something under Mac OS X platform
    else
    cecho "Y U NO USE MAC?" $red
  23. Brandon Brown revised this gist May 15, 2014. 1 changed file with 414 additions and 414 deletions.
    828 changes: 414 additions & 414 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -35,417 +35,417 @@ else
    fi


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

    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 "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 ""
    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 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 &

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

    # 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 "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' 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 ""
    # 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 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
  24. Brandon Brown revised this gist May 15, 2014. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,14 @@ cecho() {
    return
    }

    # Check platform
    if [ "$(uname)" == "Darwin" ]; then
    # Do something under Mac OS X platform
    else
    cecho "Y U NO USE MAC?" $red
    echo "(╯°□°)╯︵ ┻━┻"
    fi


    # Ask for the administrator password upfront
    sudo -v
  25. 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
    @@ -18,8 +18,8 @@ cyan='\033[0;36m'
    alias Reset="tput sgr0"

    # Color-echo.
    # Argument $1 = message
    # Argument $2 = Color
    # arg $1 = message
    # arg $2 = Color
    cecho() {
    echo "${2}${1}"
    Reset # Reset to normal.
  26. Brandon Brown revised this gist May 15, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    #!/bin/sh

    # Some things taken from here
    # https://github.com/mathiasbynens/dotfiles/blob/master/.osx

    # Set the colours you can use
    black='\033[0;30m'
    white='\033[0;37m'
    red='\033[0;31m'
    @@ -10,8 +14,8 @@ magenta='\033[0;35m'
    cyan='\033[0;36m'


    alias Reset="tput sgr0" # Reset text attributes to normal
    #+ without clearing screen.
    # Reset text attributes to normal + without clearing screen.
    alias Reset="tput sgr0"

    # Color-echo.
    # Argument $1 = message
    @@ -22,8 +26,6 @@ cecho() {
    return
    }

    # Some things taken from here
    # https://github.com/mathiasbynens/dotfiles/blob/master/.osx

    # Ask for the administrator password upfront
    sudo -v
  27. Brandon Brown revised this gist May 15, 2014. 1 changed file with 82 additions and 85 deletions.
    167 changes: 82 additions & 85 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -32,164 +32,161 @@ sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

    echo ""
    cecho "#####################################"
    cecho "## This script will make your Mac awesome."
    cecho "## Follow the prompts and you'll be fine."
    cecho "#####################################"
    echo ""
    echo ""
    cecho "#####################################"
    cecho "## Happy Hacking!"
    cecho "#####################################"
    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 ""
    cecho "Setting your computer name (as done via System Preferences → Sharing)"
    cecho "What would you like it to be?"
    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 ""
    cecho "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 ""
    cecho "Disabling OS X Gate Keeper"
    cecho "(You'll be able to install any app you want from here on, not just Mac App Store apps)"
    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 ""
    cecho "Increasing the window resize speed for Cocoa applications whether you like it or not"
    echo "Increasing the window resize speed for Cocoa applications whether you like it or not"
    defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

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

    echo ""
    cecho "Disabling the 'Are you sure you want to open this application from the Internet?' dialog"
    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 ""
    cecho "Displaying ASCII control characters using caret notation in standard text views"
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

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

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

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

    echo ""
    cecho "Reveal IP address, hostname, OS version, etc. when clicking the clock in the login window"
    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 ""
    cecho "Never go into computer sleep mode"
    echo "Never go into computer sleep mode"
    systemsetup -setcomputersleep Off > /dev/null

    echo ""
    cecho "Check for software updates daily, not just once per week"
    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 ""
    cecho "Increasing sound quality for Bluetooth headphones/headsets"
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

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

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

    echo ""
    cecho "Setting a blazingly fast keyboard repeat rate (ain't nobody got time fo special chars while coding!)"
    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 ""
    cecho "Disabling auto-correct"
    echo "Disabling auto-correct"
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

    echo ""
    cecho "Setting trackpad & mouse speed to a reasonable number"
    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 ""
    cecho "Turn off keyboard illumination when computer is not used for 5 minutes"
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300

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

    echo ""
    cecho "Requiring password immediately after sleep or screen saver begins"
    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 ""
    cecho "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    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 ""
    cecho "Setting location to ~/Desktop"
    echo "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    cecho "Setting location to ~/$screenshot_location"
    echo "Setting location to ~/$screenshot_location"
    defaults write com.apple.screencapture location -string "$HOME/$screenshot_location"
    fi

    echo ""
    cecho "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    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 ""
    cecho "Setting screenshot format to PNG"
    echo "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    cecho "Setting screenshot format to $screenshot_format"
    echo "Setting screenshot format to $screenshot_format"
    defaults write com.apple.screencapture type -string "$screenshot_format"
    fi


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

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

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

    echo ""
    cecho "Finder: show hidden files by default?"
    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
    @@ -199,7 +196,7 @@ select yn in "Yes" "No"; do
    done

    echo ""
    cecho "Finder: show dotfiles?"
    echo "Finder: show dotfiles?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    @@ -209,51 +206,51 @@ select yn in "Yes" "No"; do
    done

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

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

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

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

    echo ""
    cecho "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 ""
    cecho "Disabling the warning when changing a file extension"
    echo "Disabling the warning when changing a file extension"
    defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

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

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

    echo ""
    cecho "Disabling disk image verification"
    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 ""
    cecho "Enable snap-to-grid for icons on the desktop and in other icon views?"
    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 ""
    cecho "Setting Trash to empty securely by default"
    echo "Setting Trash to empty securely by default"
    defaults write com.apple.finder EmptyTrashSecurely -bool true


    @@ -267,26 +264,26 @@ defaults write com.apple.finder EmptyTrashSecurely -bool true
    #defaults write com.apple.dock persistent-apps -array

    echo ""
    cecho "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    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 ""
    cecho "Speeding up Mission Control animations and grouping windows by application"
    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 ""
    cecho "Setting Dock to auto-hide and removing the auto-hiding delay"
    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 ""
    cecho "Setting Dock to 2D mode"
    echo "Setting Dock to 2D mode"
    defaults write com.apple.dock no-glass -boolean YES

    echo ""
    cecho "Pinning the Dock to the left side of the screen for most efficient use of screen realestate"
    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"


    @@ -295,41 +292,41 @@ cecho "Pinning the Dock to the left side of the screen for most efficient use of
    ###############################################################################

    echo ""
    cecho "Disabling Safari’s 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 ""
    cecho "Enabling Safari’s debug menu"
    echo "Enabling Safari’s debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

    echo ""
    cecho "Making Safari’s 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 ""
    cecho "Removing useless icons from Safari’s bookmarks bar"
    echo "Removing useless icons from Safari’s bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"

    echo ""
    cecho "Enabling the Develop menu and the Web Inspector in Safari"
    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 ""
    cecho "Adding a context menu item for showing the Web Inspector in web views"
    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 ""
    cecho "Enabling iTunes track notifications in the Dock"
    echo "Enabling iTunes track notifications in the Dock"
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    cecho "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app?"
    echo "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    @@ -339,15 +336,15 @@ select yn in "Yes" "No"; do
    done

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

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

    echo ""
    cecho "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    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"
    @@ -357,51 +354,51 @@ defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
    ###############################################################################

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

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

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

    echo ""
    cecho "Speed up wake from sleep to 24 hours from an hour"
    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 ""
    cecho "Disable computer sleep and stop the display from shutting off"
    echo "Disable computer sleep and stop the display from shutting off"
    sudo pmset -a sleep 0
    sudo pmset -a displaysleep 0

    echo ""
    cecho "Disabling OS X logging of downloaded files"
    cecho "For more info visit http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/"
    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 ""
    cecho "Do you use Sublime Text as your editor of choice and is it installed?"
    echo "Do you use Sublime Text as your editor of choice and is it installed?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) echo ""
    cecho "Linking Sublime Text command line"
    echo "Linking Sublime Text command line"
    ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    echo ""
    cecho "Setting Git to use Sublime Text as default editor"
    echo "Setting Git to use Sublime Text as default editor"
    git config --global core.editor "subl -n -w"
    echo ""
    cecho "Removing Mission Control as it interferes with Sublime Text keyboard shortcut for selecting multiple lines"
    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;;
    @@ -413,10 +410,10 @@ done
    # Git
    ###############################################################################
    echo ""
    cecho "Create a nicely formatted git log command accessible via 'git lg'?"
    echo "Create a nicely formatted git log command accessible via 'git lg'?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) cecho "Creating nice git log command"
    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;;
    @@ -428,14 +425,14 @@ done
    ###############################################################################

    echo ""
    cecho "Done!"
    echo "Done!"
    echo ""
    echo ""
    cecho "###############################################################################"
    echo "###############################################################################"
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect."
    cecho "Killing some open applications in order to take effect."
    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
  28. Brandon Brown revised this gist May 15, 2014. 1 changed file with 83 additions and 83 deletions.
    166 changes: 83 additions & 83 deletions osx-for-hackers.sh
    Original file line number Diff line number Diff line change
    @@ -32,164 +32,164 @@ 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 "#####################################"
    cecho "#####################################"
    cecho "## This script will make your Mac awesome."
    cecho "## Follow the prompts and you'll be fine."
    cecho "#####################################"
    echo ""
    echo ""
    echo "#####################################"
    echo "## Happy Hacking!"
    echo "#####################################"
    cecho "#####################################"
    cecho "## Happy Hacking!"
    cecho "#####################################"
    echo ""
    ###############################################################################
    # General UI/UX
    ###############################################################################

    echo ""
    echo "Setting your computer name (as done via System Preferences → Sharing)"
    echo "What would you like it to be?"
    cecho "Setting your computer name (as done via System Preferences → Sharing)"
    cecho "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?"
    cecho "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)"
    cecho "Disabling OS X Gate Keeper"
    cecho "(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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

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

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

    echo ""
    echo "Saving to disk (not to iCloud) by default"
    cecho "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"
    cecho "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"
    cecho "Never go into computer sleep mode"
    systemsetup -setcomputersleep Off > /dev/null

    echo ""
    echo "Check for software updates daily, not just once per week"
    cecho "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"
    cecho "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)"
    cecho "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 "
    cecho "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!)"
    cecho "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"
    cecho "Disabling auto-correct"
    defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    cecho "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"
    cecho "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"
    cecho "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)"
    cecho "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"
    cecho "Setting location to ~/Desktop"
    defaults write com.apple.screencapture location -string "$HOME/Desktop"
    else
    echo ""
    echo "Setting location to ~/$screenshot_location"
    cecho "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) "
    cecho "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"
    cecho "Setting screenshot format to PNG"
    defaults write com.apple.screencapture type -string "png"
    else
    echo ""
    echo "Setting screenshot format to $screenshot_format"
    cecho "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"
    cecho "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"
    cecho "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?"
    cecho "Finder: show hidden files by default?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.Finder AppleShowAllFiles -bool true
    @@ -199,7 +199,7 @@ select yn in "Yes" "No"; do
    done

    echo ""
    echo "Finder: show dotfiles?"
    cecho "Finder: show dotfiles?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.finder AppleShowAllFiles TRUE
    @@ -209,51 +209,51 @@ select yn in "Yes" "No"; do
    done

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

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

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

    echo ""
    echo "Finder: allowing text selection in Quick Look/Preview"
    cecho "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?"
    cecho "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"
    cecho "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"
    cecho "Use column view in all Finder windows by default"
    defaults write com.apple.finder FXPreferredViewStyle -string "clmv"

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

    echo ""
    echo "Disabling disk image verification"
    cecho "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?"
    cecho "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"
    cecho "Setting Trash to empty securely by default"
    defaults write com.apple.finder EmptyTrashSecurely -bool true


    @@ -267,26 +267,26 @@ defaults write com.apple.finder EmptyTrashSecurely -bool true
    #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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "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"


    @@ -295,41 +295,41 @@ echo "Pinning the Dock to the left side of the screen for most efficient use of
    ###############################################################################

    echo ""
    echo "Disabling Safari’s thumbnail cache for History and Top Sites"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "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"
    cecho "Enabling iTunes track notifications in the Dock"
    defaults write com.apple.dock itunes-notifications -bool true

    echo ""
    echo "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app?"
    cecho "Copy email addresses as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    @@ -339,15 +339,15 @@ select yn in "Yes" "No"; do
    done

    echo ""
    echo "Enabling the debug menu in Disk Utility"
    cecho "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"
    cecho "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"
    @@ -357,51 +357,51 @@ defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
    ###############################################################################

    echo ""
    echo "Preventing Time Machine from prompting to use new hard drives as backup volume"
    cecho "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"
    cecho "Disabling local Time Machine backups"
    hash tmutil &> /dev/null && sudo tmutil disablelocal

    ###############################################################################
    # Personal Additions
    ###############################################################################
    echo ""
    echo "Deleting space hogging sleep image and disabling"
    cecho "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"
    cecho "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"
    cecho "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/"
    cecho "Disabling OS X logging of downloaded files"
    cecho "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 as your editor of choice and is it installed?"
    cecho "Do you use Sublime Text 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"
    cecho "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"
    cecho "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"
    cecho "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;;
    @@ -413,10 +413,10 @@ done
    # Git
    ###############################################################################
    echo ""
    echo "Create a nicely formatted git log command accessible via 'git lg'?"
    cecho "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"
    Yes ) cecho "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;;
    @@ -428,14 +428,14 @@ done
    ###############################################################################

    echo ""
    echo "Done!"
    cecho "Done!"
    echo ""
    echo ""
    echo "###############################################################################"
    cecho "###############################################################################"
    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."
    cecho "Killing some open applications in order to take effect."
    echo ""

    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
  29. 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
    @@ -1,4 +1,4 @@
    #! /bin/sh
    #!/bin/sh

    black='\033[0;30m'
    white='\033[0;37m'
  30. Brandon Brown revised this gist May 15, 2014. No changes.