Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Eduardo Lundgren
312 lines (230 sloc) 16.215 kb
#!/usr/bin/env bash
# Inspired by ~/.osx — http://mths.be/osx
OSX=$(test "`uname`" == "Darwin" && echo "x")
if [[ OSX ]]; then
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
############################################################################
# General UI/UX #
############################################################################
# Set computer name (as done via System Preferences → Sharing)
sudo scutil --set ComputerName "<%- osx.computername %>"
sudo scutil --set LocalHostName "<%- osx.computername %>"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "<%- osx.computername %>"
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
# Menu bar: show remaining battery time (on pre-10.8); hide percentage
defaults write com.apple.menuextra.battery ShowPercent -string "NO"
defaults write com.apple.menuextra.battery ShowTime -string "YES"
# General: Enable save documents to iCloud
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool <%- osx.general_icloud %>
# General: automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool <%- osx.general_printer %>
# General: enable the "Are you sure you want to open this application?" dialog
defaults write com.apple.LaunchServices LSQuarantine -bool <%- osx.general_dialog %>
# 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
# Restart automatically if the computer freezes
systemsetup -setrestartfreeze on
# General: enable smart quotes, they're annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool <%- osx.general_quotes %>
# General: enable smart dashes, they're annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool <%- osx.general_dashes %>
############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
############################################################################
# Trackpad: enable tap to click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool <%- osx.trackpad_tap %>
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Trackpad: enable bottom right corner to right-click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool <%- osx.trackpad_corner %>
defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool <%- osx.trackpad_corner %>
# General: enable "natural" (Lion-style) scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool <%- osx.general_scroll %>
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Enable full keyboard access for all controls
# (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# General: enable scroll gesture with the Ctrl (^) modifier key to zoom
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool <%- osx.general_zoom %>
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
# Follow the keyboard focus while zoomed in
defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool <%- osx.general_zoom %>
# General: enable press-and-hold for keys instead of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool <%- osx.general_repeat %>
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
# General: automatically illuminate built-in MacBook keyboard in low light
defaults write com.apple.BezelServices kDim -bool <%- osx.general_illuminate %>
# Turn off keyboard illumination when computer is not used for 5 minutes
defaults write com.apple.BezelServices kDimTime -int 300
# Set language and text formats
# Note: if you’re in the US, you may replace `EUR` with `USD`, `Centimeters`
# with `Inches`, `en_GB` with `en_US`, and `true` with `false`.
defaults write NSGlobalDomain AppleLanguages -array "en"
defaults write NSGlobalDomain AppleLocale -string "en_US@currency=USD"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool <%- osx.general_metric %>
# General: enable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool <%- osx.general_autocorrect %>
############################################################################
# Screen #
############################################################################
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Save screenshots to ~/Screenshots
mkdir -p "${HOME}/Screenshots"
defaults write com.apple.screencapture location -string "${HOME}/Screenshots"
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# General: enable HiDPI display modes (requires restart)
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool <%- osx.general_hidpi %>
############################################################################
# Finder #
############################################################################
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool <%- osx.finder_quit %>
# Finder: disable window and Get Info animations
defaults write com.apple.finder DisableAllAnimations -bool <%- osx.finder_animation %>
# General: Enable icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool <%- osx.general_icons %>
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool <%- osx.general_icons %>
defaults write com.apple.finder ShowMountedServersOnDesktop -bool <%- osx.general_icons %>
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool <%- osx.general_icons %>
# Finder: show hidden files by default
defaults write com.apple.finder AppleShowAllFiles -bool <%- osx.finder_hidden %>
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool <%- osx.finder_extension %>
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool <%- osx.finder_statusbar %>
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool <%- osx.finder_pathbar %>
# Finder: allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool <%- osx.finder_selection %>
# Finder: display full path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool <%- osx.finder_path %>
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# General: enable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool <%- osx.general_extension %>
# Finder: enable spring loading for directories
defaults write NSGlobalDomain com.apple.springing.enabled -bool <%- osx.finder_spring %>
# Remove the spring loading delay for directories
defaults write NSGlobalDomain com.apple.springing.delay -float 0
# General: create .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool <%- osx.general_dstore %>
# Finder: automatically open a new window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool <%- osx.finder_window %>
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool <%- osx.finder_window %>
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool <%- osx.finder_window %>
# Show item info near icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :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
# Show item info to the right of the icons on the desktop
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
# 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
# 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
# Increase the size of icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 64" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 64" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 64" ~/Library/Preferences/com.apple.finder.plist
# Use columns view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `Nlsv`, `Flwv`
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
# General: enable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool <%- osx.general_trash %>
# Finder: enable AirDrop over Ethernet and on unsupported Macs running Lion
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool <%- osx.finder_airdrop %>
# Show the ~/Library folder
chflags nohidden ~/Library
############################################################################
# Dock, Dashboard, and hot corners #
############################################################################
# Dock: enable highlight hover effect for the grid view of a stack
defaults write com.apple.dock mouse-over-hilite-stack -bool <%- osx.dock_highlight %>
# Set the icon size of Dock items to 48 pixels
defaults write com.apple.dock tilesize -int 48
# Dock: enable magnification
defaults write com.apple.dock magnification -bool <%- osx.dock_magnification %>
# Set magnification icon size to 80 pixels
defaults write com.apple.dock largesize -float 80
# Dock: minimize windows into their application's icon
defaults write com.apple.dock minimize-to-application -bool <%- osx.dock_minimize %>
# Dock: enable spring loading for all Dock items
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool <%- osx.dock_spring %>
# Dock: enable animation when opening applications
defaults write com.apple.dock launchanim -bool <%- osx.dock_animation %>
# Speed up Mission Control animations
defaults write com.apple.dock expose-animation-duration -float 0.1
# General: enable Dashboard as an overlay
defaults write com.apple.dock dashboard-in-overlay -bool <%- osx.general_dashboard %>
# General: automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool <%- osx.general_spaces %>
# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Speed up animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0.3
# Dock: automatically hide and show
defaults write com.apple.dock autohide -bool <%- osx.dock_autohide %>
# Dock: make icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool <%- osx.dock_translucent %>
# Reset Launchpad
find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
# Hot corners
# Possible values:
# 0: no-op
# 2: Mission Control
# 3: Show application windows
# 4: Desktop
# 5: Start screen saver
# 6: Disable screen saver
# 7: Dashboard
# 10: Put display to sleep
# 11: Launchpad
# 12: Notification Center
# Top left screen corner → Dashboard
defaults write com.apple.dock wvous-tl-corner -int 7
defaults write com.apple.dock wvous-tl-modifier -int 0
# Top right screen corner → Desktop
defaults write com.apple.dock wvous-tr-corner -int 4
defaults write com.apple.dock wvous-tr-modifier -int 0
# Bottom left screen corner → Mission Control
defaults write com.apple.dock wvous-bl-corner -int 2
defaults write com.apple.dock wvous-bl-modifier -int 0
# Bottom right screen corner → Launchpad
defaults write com.apple.dock wvous-br-corner -int 11
defaults write com.apple.dock wvous-br-modifier -int 0
############################################################################
# Terminal & iTerm 2 #
############################################################################
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
# iTerm: enable prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool <%- osx.iterm_prompt %>
############################################################################
# Kill affected applications #
############################################################################
for app in "Dock" "Finder" "SystemUIServer" "Terminal" "iCal"; do
killall "${app}" > /dev/null 2>&1
done
echo "Done. Note that some of these changes require a logout/restart to take effect."
else
echo "Skipping ~/.osx evaluation..."
fi
Jump to Line
Something went wrong with that request. Please try again.