Skip to content

Instantly share code, notes, and snippets.

@CoderPiF
Forked from ryanpcmcquen/.osx
Created February 17, 2017 02:19
Show Gist options
  • Save CoderPiF/5c508d56761173bea4fb0b980b4afc47 to your computer and use it in GitHub Desktop.
Save CoderPiF/5c508d56761173bea4fb0b980b4afc47 to your computer and use it in GitHub Desktop.
.osx
#!/usr/bin/env bash
## Adapted from:
## https://mths.be/osx & https://github.com/ssorallen/dotfiles/blob/master/.osx
##
## curl -O https://gist.githubusercontent.com/ryanpcmcquen/b2e608311f286a4ab3e1/raw/.osx
###############################################################################
# General UI/UX #
###############################################################################
## Make boot quieter (hopefully):
#sudo nvram SystemAudioVolume=" "
## Make the booting verbose (feels more unix-y & hacker-y):
#sudo nvram boot-args="-v"
# Automatically quit printer app once the print jobs complete:
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Disable smart quotes as they’re annoying when typing code.
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable smart dashes as they’re annoying when typing code.
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
## Make sure all services show up in the right-click menu:
defaults write -g NSServicesMinimumItemCountForContextSubmenu -int 999
## Remove shadow from screenshots:
defaults write com.apple.screencapture disable-shadow -bool true
## Turn off ui sounds:
defaults write com.apple.systemsound "com.apple.sound.uiaudio.enabled" -int 0
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
# Trackpad: DISABLE tap to click for this user and for the login screen.
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool false
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 0
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 0
# Enable full keyboard access for all controls,
# (e.g. enable Tab in modal dialogs).
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Use scroll gesture with the Ctrl (^) modifier key to zoom:
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
# Set a shorter delay until key repeat:
defaults write NSGlobalDomain InitialKeyRepeat -int 11
# Set a blazingly fast keyboard repeat rate:
defaults write NSGlobalDomain KeyRepeat -int 1
## Allow fast key repeat in gui apps:
defaults write -g ApplePressAndHoldEnabled -bool false
###############################################################################
# Screen #
###############################################################################
# Require password 5s after sleep or screen saver begins:
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 5
###############################################################################
# Finder #
###############################################################################
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Empty trash securely by default:
defaults write com.apple.finder EmptyTrashSecurely -bool true
## Empty trash non-securely by default:
#defaults write com.apple.finder EmptyTrashSecurely -bool false
# Always open everything in Finder's list view. This is important.
defaults write com.apple.finder FXPreferredViewStyle Nlsv
# Show the ~/Library folder.
chflags nohidden ~/Library
###############################################################################
# Dock, Dashboard, and hot corners #
###############################################################################
# Disable Dashboard:
defaults write com.apple.dashboard mcx-disabled -bool true
## Disable mission control:
#defaults write com.apple.dock mcx-expose-disabled -bool true
# Automatically hide and show the Dock:
defaults write com.apple.dock autohide -bool true
# Put the dock on the bottom side of the screen:
defaults write com.apple.dock orientation -string bottom
## Make the dock crazy small, since I do not really use it.
defaults write com.apple.dock tilesize -int 8
## Make the dock only show open apps:
defaults write com.apple.dock static-only -bool true
# 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
# Bottom left screen corner → Put display to sleep.
defaults write com.apple.dock wvous-bl-corner -int 10
defaults write com.apple.dock wvous-bl-modifier -int 0
###############################################################################
# Safari & WebKit #
###############################################################################
# Privacy: don’t send search queries to Apple.
defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
# Set Safari’s home page to `about:blank` for faster loading:
defaults write com.apple.Safari HomePage -string "about:blank"
# Prevent Safari from opening ‘safe’ files automatically after downloading:
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
# Hide Safari’s bookmarks bar by default:
defaults write com.apple.Safari ShowFavoritesBar -bool false
# Enable Safari’s debug menu:
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Enable the Develop menu and the Web Inspector in Safari:
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
###############################################################################
# Terminal #
###############################################################################
# Only use UTF-8 in Terminal.app:
defaults write com.apple.terminal StringEncodings -array 4
# Use the Pro theme by default in Terminal.app
## Actually, 'Pro' looks terrible on a projector.
# osascript <<EOD
# tell application "Terminal"
# local allOpenedWindows
# local initialOpenedWindows
# local windowID
# set themeName to "Pro"
# (* Set Pro as the default terminal theme. *)
# set default settings to settings set themeName
# end tell
# EOD
###############################################################################
# XCode #
###############################################################################
# Prevent XCode from reopening potentially large workspaces on launch:
defaults write com.apple.dt.Xcode ApplePersistenceIgnoreState YES
###############################################################################
## Animations ##
###############################################################################
# Opening and closing windows and popovers:
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# Smooth scrolling:
defaults write -g NSScrollAnimationEnabled -bool false
# Showing and hiding sheets, resizing preference windows, zooming windows,
# (float 0 doesn't work).
defaults write -g NSWindowResizeTime -float 0.001
# Opening and closing Quick Look windows:
defaults write -g QLPanelAnimationDuration -float 0
# Rubberband scrolling (does not affect web views):
defaults write -g NSScrollViewRubberbanding -bool false
# Resizing windows before and after showing the version browser.
# Also disabled by NSWindowResizeTime -float 0.001:
defaults write -g NSDocumentRevisionsWindowTransformAnimation -bool false
# Showing a toolbar or menu bar in full screen:
defaults write -g NSToolbarFullScreenAnimationDuration -float 0
# Scrolling column views:
defaults write -g NSBrowserColumnAnimationSpeedMultiplier -float 0
# Showing the Dock:
defaults write com.apple.dock autohide-time-modifier -float 0
defaults write com.apple.dock autohide-delay -float 0
# Showing and hiding Mission Control, command+numbers:
defaults write com.apple.dock expose-animation-duration -float 0
# Showing and hiding Launchpad:
defaults write com.apple.dock springboard-show-duration -float 0
defaults write com.apple.dock springboard-hide-duration -float 0
# Changing pages in Launchpad:
defaults write com.apple.dock springboard-page-duration -float 0
# At least AnimateInfoPanes:
defaults write com.apple.finder DisableAllAnimations -bool true
# Sending messages and opening windows for replies:
defaults write com.apple.Mail DisableSendAnimations -bool true
defaults write com.apple.Mail DisableReplyAnimations -bool true
####################
# Disable iTunes #
####################
#osascript -e 'tell application "System Events" to delete login item "iTunesHelper"'
#osascript -e 'tell application "System Events" to delete login item "iTunes"'
#sudo chmod -x /Applications/iTunes.app
#sudo mv /Applications/iTunes.app/Contents/MacOS/iTunes /private/tmp/
##
## Some other useful osascript examples:
## osascript -e 'tell application "System Events" to make login item at end with properties {path:"/path/to/itemname", hidden:false}'
## osascript -e 'tell application "System Events" to delete login item "itemname"'
## osascript -e 'tell application "System Events" to get the name of every login item'
##
##########
# config #
##########
## Get the command line tools!
xcode-select --install
## You have to do this at some point:
sudo xcodebuild -license accept
## Install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
## Need these:
brew install tmux lftp httrack node hg watchman flow
## I do not need homebrew ruby,
## but Mac OS' Ruby is really broken.
##brew install ruby
## Atom goodies:
[ `which atom` ] && apm install atom-beautify nuclide atom-ternjs language-diff language-haskell language-lua emmet-simplified
## Install imgult if it isn't there:
if [ -z "`which imgult`" ]; then
curl https://gist.githubusercontent.com/ryanpcmcquen/2cb42266052a57992d55/raw/install-right-click-imgult-mac.sh | sh
fi
## Create somewhere to make noise:
mkdir -pv ~/scratchPad/
## Grab my .bash_profile, running allup from that grabs other stuff (imgult, vimrc):
curl -o ~/.bash_profile https://gist.githubusercontent.com/ryanpcmcquen/9518163/raw/.bash_profile
## Make atom the default for a lot of stuff:
if [ -z "`defaults read com.apple.LaunchServices | grep atom`" ]; then
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.text;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.content;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.data;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.source-code;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.script;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.shell-script;LSHandlerRoleAll=com.github.atom;}'
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.executable;LSHandlerRoleAll=com.github.atom;}'
fi
###############################################################################
# Kill affected applications #
###############################################################################
for app in "cfprefsd" "Dock" "Finder" "Mail" "Messages" "Safari" \
"SystemUIServer"; do
killall "${app}" > /dev/null 2>&1
done
echo "Done. Note that some of these changes require a logout/restart to take effect."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment