Skip to content

Instantly share code, notes, and snippets.

@baseboxorg
Forked from NoteHub/osx-10.10-setup.md
Last active August 29, 2015 14:10
Show Gist options
  • Save baseboxorg/beca70dee2f87498279e to your computer and use it in GitHub Desktop.
Save baseboxorg/beca70dee2f87498279e to your computer and use it in GitHub Desktop.

Mac OS X 10.10 Yosemite

While rebuilding I prefer as much verbose automation as possible.

2014-10-29 This gist is too big, see https://github.com/NoteHub/osx

Read this document through and fork/use the good parts to your preferences.

1. System preferences

Save the following commands as system-preferences.sh and run bash system-preferences.sh

###############################################################################
# General                                                                     #
###############################################################################

echo Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0.02

echo Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12

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

echo Show the ~/Library folder
chflags nohidden ~/Library

echo Store screenshots in subfolder on desktop
# defaults write com.apple.screencapture location -string "$HOME/Desktop"
mkdir ~/Desktop/Screenshots
defaults write com.apple.screencapture location ~/Desktop/Screenshots

echo "Setup computer name"
sudo scutil --set ComputerName "DarthVadersLaptop"
sudo scutil --set HostName "DarthVadersLaptop"
sudo scutil --set LocalHostName "DarthVadersLaptop"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "DarthVadersLaptop"

echo "tame the aspd process"
# to reenable, sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.apsd.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist

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

echo "Disable Notification Center and remove the menu bar icon"
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist

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

echo "Show percentage in battery status"
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
defaults write com.apple.menuextra.battery ShowTime -string "NO"

echo "Fix fonth smoothing"
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0

echo "Enable repeat on keydown"
defaults write -g ApplePressAndHoldEnabled -bool false

echo "Use current directory as default search scope in Finder"
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"

echo "Show Path bar in Finder"
defaults write com.apple.finder ShowPathbar -bool true

echo "Show Status bar in Finder"
defaults write com.apple.finder ShowStatusBar -bool true

echo "Set a blazingly fast keyboard repeat rate"
defaults write NSGlobalDomain KeyRepeat -int 0.02

echo "Set a shorter Delay until key repeat"
defaults write NSGlobalDomain InitialKeyRepeat -int 12

echo "Show the ~/Library folder"
chflags nohidden ~/Library

echo "Disable rubberband scrolling"
defaults write -g NSScrollViewRubberbanding -bool false

echo "Disable dashboard"
defaults write com.apple.dashboard mcx-disabled -boolean YES

echo "Move dock to left side of screen"
defaults write com.apple.dock orientation -string left

echo "Hide dock automatically"
defaults write com.apple.dock autohide -boolean true

echo "Show all filename extensions in Finder"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

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

echo "Expand print panel by default"
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true

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

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

echo "Require password after a minute after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 60

echo "Use list view in all Finder windows by default"
echo "Four-letter codes for the other view modes: icnv, Nlmv, Flwv"
defaults write com.apple.finder FXPreferredViewStyle -string "Nlmv"

echo "Remove default text from basic screen saver"
defaults write ~/Library/Preferences/com.apple.ScreenSaver.Basic MESSAGE " "

echo "Disable sound effect when changing volume"
defaults write -g com.apple.sound.beep.feedback -integer 0

echo "Disable user interface sound effects"
defaults write com.apple.systemsound 'com.apple.sound.uiaudio.enabled' -int 0

echo "Set system sounds volume to 0"
defaults write com.apple.systemsound com.apple.sound.beep.volume -float 0

###############################################################################
# Trackpad, Mouse, Keyboard, Gestures                                         #
###############################################################################

echo "Enable tap to click (Trackpad)"
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 "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

echo "Follow mouse when zoomed in"
defaults write com.apple.universalaccess closeViewPanningMode -int 0

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

echo "Tap with two fingers to emulate right click"
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true

echo "Disable three finger drag"
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool false

echo "Disable automatic rearrangement of spaces based on most recent usage"
defaults write com.apple.dock mru-spaces -bool false

###############################################################################
# Activity monitor                                                            #
###############################################################################

echo "Sort Activity Monitor results by CPU usage"
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0

echo "Kill affected applications, so the changes apply"
for app in Safari Finder Dock Mail SystemUIServer; do killall "$app" >/dev/null 2>&1; done

After that, you have to do some settings manually. I'm scripting the homebrew options below and will post bash soon. these settings did not have effect when using defaults write

2. Install Software

The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.

Install from App Store

Install from Third-Party Websites

Fonts

Mensch coding font

#Xcode Command Line Tools

Xcode > Preferences > Downloads > Command Line Tools

#Homebrew

3. Install Homebrew

Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes. Open Terminal and run the following command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor

Once complete you should see;

==> Installation successful!
==> Next steps
Run `brew doctor` before you install anything
Run `brew help` to get started*

Install Homebrew extension Cask

brew install caskroom/cask/brew-cask

Install common applications via Homebrew

Databases are installed later.

brew install ack autojump automake colordiff curl git git-flow \
             hub icoutils imagemagick libmemcached memcached openssl ossp-uuid qt \
             readline redis tmux wget libxml2

Install applications via Homebrew Cask

brew cask install anvil
brew cask install atom
brew cask install authy-bluetooth
brew cask install awareness
brew cask install bartender
brew cask install battery-guardian
brew cask install github
brew cask install google-chrome
brew cask install joinme
brew cask install iterm2
brew cask install virtualbox
brew cask install rescuetime
brew cask install rubymine
brew cask install satellite-eyes
brew cask install sidestep
brew cask install sonos
brew cask install steam
brew cask install vagrant
brew cask install vagrant-manager
When you have difficult binaries to install like OpenCV or other complicated, it might be easier to install them to a vagrant box. Sometimes you just want to `sudo apt-get install python-opencv python-numpy`.

If you don't want to pollute your OS X with tons of libraries and binaries(e.g. ruby gems/python packages), you can always spin up a vagrant box. For example you could have one vagrant box for running Python software and another for Ruby.

#Shell

Install custom .dotfiles anc customize this

git clone git@github.com:kevinelliott/.dotfiles.git ~/.dotfiles
~/.dotfiles/install.sh

Update .bash_profile

echo 'source ~/.dotfiles/base.sh' >> ~/.bash_profile

#Git

Setup Github

ssh-keygen -t rsa -C "darthvader@empire.org"

# Copy ssh key to github.com
subl ~/.ssh/id_rsa.pub

# Test connection
ssh -T git@github.com

# Set git config values
git config --global user.name "Darth Vader"
git config --global user.email "darthvader@empire.org"
git config --global github.user darthvader
git config --global github.token your_token_here

git config --global core.editor "subl -w"
git config --global color.ui true

Sublime Text

Add Sublime Text CLI

mkdir -p ~/bin && ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Install Package Control

Run Sublime Text 3 and access the console via the CTRL + ``` shortcut or the View > Show Console` menu.

import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

See https://sublime.wbond.net/installation for more information. Their site has a note that this install code will change for each new release, so it would be good to check once in a while.

Install Packages

BracketHighlighter CoffeeScriptHaml

Install Soda Theme

git clone git://github.com/buymeasoda/soda-theme.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Theme\ -\ Soda

Install Tomorrow Theme

git clone git://github.com/chriskempson/textmate-tomorrow-theme.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Color\ Scheme\ -\ Tomorrow

Settings

Sublime Text > Preferences > Settings - User

{
    "close_windows_when_empty": true,
    "color_scheme": "Packages/Color Scheme - Tomorrow/Tomorrow-Night-Eighties.tmTheme",
    "draw_indent_guides": false,
    "font_face": "Mensch",
    "font_size": 18,
    "highlight_modified_tabs": true,
    "show_tab_close_buttons": false,
    "tab_size": 2,
    "spell_check": false,
    "theme": "Soda Light.sublime-theme",
    "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
}

Key Bindings

[
	{ "keys": ["super+b"], "command": "expand_selection", "args": {"to": "brackets"} },
	{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "replace"} },
	{ "keys": ["super+alt+f"], "command": "show_panel", "args": {"panel": "find"} }
]

Snippets

git clone git@github.com:bytestudios/sublime-snippets.git "/Users/DarthVader/Library/Application Support/Sublime Text 2/Packages/Byte"

Server

I need to try installing docker on Mac including VirtualBox and boot2docker dependencies with one simple command.

https://github.com/thlorenz/docmac
curl -L https://raw.github.com/thlorenz/docmac/master/bin/docmac.sh | sh

Docker

Boot2docker is a small script that helps download and setup a minimal Linux VM that will be in charge of running docker daemon.

brew install docker boot2docker
boot2docker init
boot2docker up

and check out your new environment.

export DOCKER_HOST=tcp://localhost:4243
docker version

MySQL

brew install mysql
brew pin mysql

MySQL Settings

# Copy launch agent into place
mkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/VERSION/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/

# Edit launch agent and set both keepalive and launch at startup to false
vi ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# Inject launch agent
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# Set up databases to run as your user account
unset TMPDIR && mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

# Start mysql
start mysql

# Secure mysql
/usr/local/Cellar/mysql/VERSION/bin/mysql_secure_installation

PostgreSQL

brew install postgres --no-ossp-uuid
brew pin postgres

PostgreSQL Settings

# Initialize db if none exists already
initdb /usr/local/var/postgres

# Create launchctl script
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/VERSION/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

# Edit launchctl script (set to not start automatically and keepalive false)
subl ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

# Inject launchctl script
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

# Start PostgreSQL
start pg

Ruby Gems

Include and test better Ruby install here;
https://gorails.com/setup/osx/10.10-yosemite

libv8 / therubyracer

brew uninstall v8
gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v 3.16.14.3 -- --with-system-v8

nokogiri

brew tap homebrew/dupes
brew install libxml2 libxslt libiconv
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/VERSION/

capybara-webkit

brew install -v https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD --without-ssse3
gem install capybara-webkit -v '0.9.0'

Drag and drop installs

  • BetterTouchTool

    Productivity app for creating gesture/mouse/keyboard shortcuts to about any action you can imagine. For example I have binded 3 finger tap to middle click, 3 finger left/right swipes to changing browser/text editor tabs and more.

    I tested moom as an alternative, but BetterTouchTool has more features and is free. BetterTouchTool also ships with a killer feature that I've missed most from Ubuntu(Gnome), check it out: https://www.youtube.com/watch?v=wUeKjkpBdCo

Not that trivial installs

  • z for autojump

    Instead of cd ~/code/personal/projects/secret/mysecretproject you can just z mysecretproject. Fast.

    Install:

      mkdir ~/.bin
      cd ~/.bin
      git clone https://github.com/rupa/z.git
      echo "source ~/.bin/z/z.sh" >> ~/.zshrc
    
  • scm_breeze

    Useful helper commands/aliases for git and others

  • Vagrant

    When you have difficult binaries to install like OpenCV or other complicated, it might be easier to install them to a vagrant box. Sometimes you just want to sudo apt-get install python-opencv python-numpy.

    If you don't want to pollute your OS X with tons of libraries and binaries(e.g. ruby gems/python packages), you can always spin up a vagrant box. For example you could have one vagrant box for running Python software and another for Ruby.

  • Docker

    "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications."

    "Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud."

  • Real Python with Virtualenv

    OS X ships with its own Python but I recommend installing Python with brew. It makes setupping pip and other Python tools easier.

    Make sure that your brew installed Python is the one that you are running. If which python outputs /usr/bin/python. Then you need to add /usr/local/bin to your PATH before /usr/bin.

    After installing virtualenv with pip, install also mkvirtualenv for your convenience.

  • Ruby version manager

  • NodeJS + NPM

    Install with: pkg, brew or nvm. I prefer brew.

  • Postgres

    Mavericks does not have Postgres installed by default anymore: http://stackoverflow.com/questions/19611505/does-postgresql-exist-on-os-x-mavericks

    I think using http://postgresapp.com is the preferred way. Using brew might be fine also, don't know.

  • Windows virtual machines with IE versions

    Microsoft provides virtual machines for different Windows + IE version combinations for your testing convenience.

Further reading

A lot of this information comes from these sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment