#! /bin/bash # Alot of these configs have been taken from the various places # on the web, most from here # https://github.com/mathiasbynens/dotfiles/blob/master/.osx # Set the colours you can use # black='\033[0;30m' white='\033[0;37m' red='\033[0;31m' # green='\033[0;32m' # yellow='\033[0;33m' # blue='\033[0;34m' # magenta='\033[0;35m' cyan='\033[0;36m' # Resets the style reset=$(tput sgr0) # Color-echo. Improved. [Thanks @joaocunha] # arg $1 = message # arg $2 = Color cecho() { echo "${2}${1}${reset}" return } # Here we go.. ask for the administrator password upfront and run a # keep-alive to update existing `sudo` time stamp until script has finished sudo -v while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & ############################################################################### # General UI/UX ############################################################################### echo "" echo "Would you like to set your computer name (as done via System Preferences >> Sharing)? (y/n)" read -r response if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then 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" fi echo "" echo "Show Time Machine, Volume, Bluetooth, Airport, Battery, and Clock icons" # Get the system Hardware UUID and use it for the next menubar stuff for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do defaults write "${domain}" dontAutoLoad -array \ "/System/Library/CoreServices/Menu Extras/User.menu" done defaults write com.apple.systemuiserver menuExtras -array \ "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \ "/System/Library/CoreServices/Menu Extras/Volume.menu" \ "/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 "" # echo "Disable Spotlight indexing for any volume that gets mounted and has not yet been indexed before? (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # echo 'Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume.' # sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes" # fi 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 echo "" echo "Removing duplicates in the 'Open With' menu" /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user echo "" echo "Disable smart quotes and smart dashes" defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false echo "" echo "Disable Dashboard" defaults write com.apple.dashboard mcx-disabled -bool true echo "" echo "Don’t show Dashboard as a Space" defaults write com.apple.dock dashboard-in-overlay -bool true echo "" echo "Increase contrast and reduce transparency" defaults write com.apple.universalaccess increaseContrast -bool YES defaults write com.apple.universalaccess reduceTransparency -bool YES ############################################################################### # General Power and Performance modifications ############################################################################### echo "" echo "Disable the menubar transparency" defaults write com.apple.universalaccess reduceTransparency -bool true ################################################################################ # Trackpad, mouse, keyboard, Bluetooth accessories, and input ############################################################################### echo "" echo "Trackpad: enable tap to click for this user and for the login screen" defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 echo "" echo "Enable three finger drag" defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -boolean true defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerHorizSwipeGesture -boolean false defaults write com.apple.AppleMultitouchTrackpad TrackpadFourFingerHorizSwipeGesture -int 2 defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -boolean true defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerHorizSwipeGesture -boolean false defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadFourFingerHorizSwipeGesture -int 2 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 (enable Tab in modal dialogs, menu windows, etc.)" defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 echo "" echo "Disable auto-correct" defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false echo "" echo "Setting trackpad & mouse speed to a reasonable number" defaults write -g com.apple.trackpad.scaling 2 defaults write -g com.apple.mouse.scaling 2.5 echo "" echo "Disable display from automatically adjusting brightness" sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false echo "" echo "Disable keyboard from automatically adjusting backlight brightness in low light" sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Keyboard Enabled" -bool false ############################################################################### # Screen ############################################################################### echo "" echo "Requiring password immediately after sleep or screen saver begins" defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 echo "" echo "Enabling subpixel font rendering on non-Apple LCDs" defaults write NSGlobalDomain AppleFontSmoothing -int 2 ############################################################################### # Finder ############################################################################### # Show the ~/Library folder. echo "" echo "Show the ~/Library folder" chflags nohidden ~/Library # Show the home folder instead of all files when opening a new finder window echo "" echo "Show the home folder instead of all files when opening a new finder window" defaults write com.apple.finder NewWindowTarget PfHm echo "" echo "Enable calculate all sizes in Finder" /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.finder.plist" -c 'Delete "StandardViewSettings:ExtendedListViewSettings:calculateAllSizes" bool' /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.finder.plist" -c 'Add "StandardViewSettings:ExtendedListViewSettings:calculateAllSizes" bool true' /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.finder.plist" -c 'Delete "StandardViewSettings:ListViewSettings:calculateAllSizes" bool' /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.finder.plist" -c 'Add "StandardViewSettings:ListViewSettings:calculateAllSizes" bool true' echo "" echo "Show icons for external hard drives, servers, and removable media on the desktop" defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true defaults write com.apple.finder ShowMountedServersOnDesktop -bool true echo "" echo "Show all filename extensions in Finder by default" defaults write NSGlobalDomain AppleShowAllExtensions -bool true echo "" echo "Show status bar in Finder by default" defaults write com.apple.finder ShowStatusBar -bool true echo "" echo "Show path bar in Finder by default" defaults write com.apple.finder ShowPathbar -bool true echo "" echo "Disable 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 Clmv echo "" echo "Avoid creation of .DS_Store files on network volumes" defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true echo "" echo "Allowing text selection in Quick Look/Preview in Finder by default" defaults write com.apple.finder QLEnableTextSelection -bool true echo "" echo "Enable AirDrop over Ethernet and on unsupported Macs running Lion" defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true echo "" echo "Always show scroll bars" defaults write -g AppleShowScrollBars -string Always echo "" echo "When performing a search, search the current folder by default" defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" echo "" echo "Expand the following File Info panes:" echo "General, Open with, and Sharing & Permissions" defaults write com.apple.finder FXInfoPanesExpanded -dict \ General -bool true \ OpenWith -bool true \ Privileges -bool true # echo "" # echo "Show item info near icons on the desktop and in other icon views? (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist # /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist # /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist # fi # echo "" # echo "Show item info to the right of the icons on the desktop? (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # /usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist # fi 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 "Increase grid spacing for icons on the desktop and in other icon views" /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist echo "" echo "Increase the size of icons on the desktop and in other icon views" /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist ############################################################################### # Dock & Mission Control ############################################################################### echo "" echo "Don’t automatically rearrange Spaces based on most recent use" defaults write com.apple.dock mru-spaces -bool false echo "" echo "Put the dock on the right" defaults write com.apple.dock orientation -string right 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 ############################################################################### # Chrome, Safari, & WebKit ############################################################################### echo "" echo "Privacy: Don’t send search queries to Apple" defaults write com.apple.Safari UniversalSearchEnabled -bool false defaults write com.apple.Safari SuppressSearchSuggestions -bool true echo "" echo "Hiding Safari's bookmarks bar by default" defaults write com.apple.Safari ShowFavoritesBar -bool false 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 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 echo "" echo "Disabling the annoying backswipe in Chrome" defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false echo "" echo "Using the system-native print preview dialog in Chrome" defaults write com.google.Chrome DisablePrintPreview -bool true defaults write com.google.Chrome.canary DisablePrintPreview -bool true ############################################################################### # Mail ############################################################################### echo "" echo "Setting email addresses to copy as 'foo@example.com' instead of 'Foo Bar ' in Mail.app" defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false ############################################################################### # Terminal ############################################################################### echo "" echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default" defaults write com.apple.terminal StringEncodings -array 4 defaults write com.apple.Terminal "Default Window Settings" -string "Pro" defaults write com.apple.Terminal "Startup Window Settings" -string "Pro" ############################################################################### # Messages # ############################################################################### # echo "" # echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false # fi # # echo "" # echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false # fi # # echo "" # echo "Disable continuous spell checking in Messages.app? (y/n)" # read -r response # if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then # defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false # fi ############################################################################### # TextEdit, and Disk Utility ############################################################################### echo "" echo "Use plain text mode for new TextEdit documents" defaults write com.apple.TextEdit RichText -int 0 echo "" echo "Open and save files as UTF-8 in TextEdit" defaults write com.apple.TextEdit PlainTextEncoding -int 4 defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 echo "" echo "Enable the debug menu in Disk Utility" defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true defaults write com.apple.DiskUtility advanced-image-options -bool true ############################################################################### # Kill affected applications ############################################################################### echo "" cecho "Done!" "$cyan" echo "" echo "" cecho "################################################################################" "$white" echo "" echo "" cecho "Note that some of these changes require a logout/restart to take effect." "$red" cecho "Killing some open applications in order to take effect." "$red" echo "" find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \ "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \ "Terminal" "Transmission"; do killall "${app}" > /dev/null 2>&1 done