Skip to content

Instantly share code, notes, and snippets.

@tut-tuuut
Forked from m4dz/README.md
Last active August 29, 2015 14:07
Show Gist options
  • Save tut-tuuut/914c32c3648c8193d6f1 to your computer and use it in GitHub Desktop.
Save tut-tuuut/914c32c3648c8193d6f1 to your computer and use it in GitHub Desktop.

OS X ENV (re)Install

This is my personal guide to restore my configuration and setup my system for a fresh install. I use it and keep it updated frequently. Hope it will inspire you on your own way =].

Backup

Before a fresh reinstall, don't forget to backup many things. A regular ghost made with CarbonCopyCloner or Clonezilla is a good solution, but if you can't, you should save the following :

  • MySQL databases (use the script bellow)
  • User preferences
    • ~/Library/Application Support
    • ~/Library/ColorSync/Profiles
    • ~/Library/Fonts
    • ~/Library/Keychains
    • ~/Library/LaunchAgents
    • ~/Library/Preferences
    • ~/Library/QuickLook
  • Configs
    • ~/.gitconfig
    • ~/.glacier-cmd
    • ~/.gnupg
    • ~/.pow
    • ~/.powconfig
    • ~/.s3cfg
    • ~/.ssh

Another pretty good solution is to use Mackup that provides a smart way to keep your dotfiles synced in a cloud storage.

Installation

After a clean fresh install (format disk and reinstall the base OS and updates), let's install xtras.

Base

You can restore the previously backuped files. If you do so, don't forget to restore permissions : restart in Restore mode with ⌘+R, open the terminal and launch resetpassword2.

Shell

I use ZSH instead of the legacy bash shell. To do so :

$ git clone https://github.com/m4dz/oh-my-zsh.git ~/.oh-my-zsh
$ cd ~/.oh-my-zsh
$ git submodule update --init
$ cd
$ cp ~/.oh-my-zsh/custom/zshenv .zshenv
$ cp ~/.oh-my-zsh/custom/zshrc .zshrc
$ chsh -s /bin/zsh

Homebrew

Homebrew is a package manager for OS X. I use to manage my developer tools, and my desktop apps using its submanager : cask.

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
$ brew tap homebrew/php
$ brew tap homebrew/dupes
$ brew install caskroom/cask/brew-cask
$ brew tap caskroom/versions

Local DNS resolver

DNSmasq

If you do not need to use the whole stack given by Pow (including the rack server, see below) but only want to have a simple dns resolver, you should use DNSmasq. Be careful that you need Homebrew installed and configured (see previous-section). More informations are detailled here.

$ brew install dnsmasq
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf

Edit the /usr/local/etc/dnsmasq.conf file and add the following line :

address=/dev/127.0.0.1

Then enable the daemon and launch it :

$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Finally, add a resolver :

$ sudo mkdir /etc/resolver
$ sudo echo "nameserver 127.0.0.1" > /etc/resolver/dev

(Alternative) Pow

Pow is a tools that combines a local host names resolver (based on the .dev tld) and a rack server for ruby (and others) apps.

$ echo 'export POW_DST_PORT=88' >> ~/.powconfig
$ curl get.pow.cx | sh

Commons tools

Use Mackup for dotfiles syncing:

$ brew install mackup
$ mackup restore

My basic tools for everyday use.

via caskroom

$ brew cask install dropbox arq asepsis little-snitch trim-enabler alfred iterm2 istat-menus hyperdock appcleaner cocktail gpgtools firefox macdown

via Appstore

  • 1password
  • Divvy
  • Mouseposé
  • DaisyDisk
  • Simplenotegl

Development Environment

My development envrionment is a little bit complex due to many languages and apps I use everyday. You can simplify it to adapt it to your requirements.

Do not forget to add launch plist files for daemons. You can add the plist for your servers (http, PHP-FPM, Mysql,Memcached…) directly to /Library/LaunchDaemons to start it at boot with root permissions. Use brew info <package> to view extras informations. For Nginx and PHP-FPM, configure user / group to _www in config files ; for Memcache, configure plist file with UserName / GroupName daemon.

Base

$ brew install git
$ brew install ack aria2 apple-gcc42 zsh-completions zsh-syntax-highlighting gettext pidof curl ssh-copy-id s3cmd

$ brew install imagemagick --use-cms --with-freetype --use-rsvg --use-tiff
$ brew install optipng
	
$ sudo gem install --no-ri --no-rdoc lunchy
	
$ brew install nginx
$ mkdir -p /usr/local/var/log/nginx
$ chown _www /usr/local/var/log/nginx

DB

$ brew install mariadb postgresql memcached sqlite

Python

$ brew install python pyenv pyenv-virtualenv pyenv-pip-rehash

Ruby

$ brew install ruby-build rbenv rbenv-gem-rehash
$ rbenv install 2.1.3
$ gem install --no-ri --no-rdoc bundler

NodeJS

$ brew install node
$ curl http://npmjs.org/install.sh | sh
$ npm -g install bower coffee-script csslint docco grunt-cli jscs jshint

PHP

$ brew install php56 --with-fpm --with-homebrew-curl --with-homebrew-openssl --with-pgsql
$ brew install php56-apcu php56-memcached php56-xdebug php56-yaml
$ brew install drush
	
$ chmod -R ug+w /usr/local/Cellar/php56/5.6.2/lib/php
$ pear config-set php_ini /usr/local/etc/php/5.6/php.ini

Apps

via caskroom

$ brew cask install vagrant virtualbox sequel-pro google-chrome chromium firefox-aurora imagealpha imageoptim

via Appstore

  • Base
  • xScope
  • JPEGmini Lite
  • XCode

Editor

I use sublime text and store the config in a git repository.

$ brew cask install sublime-text3
$ git clone https://github.com/m4dz/ST3-User-package ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User

Apps

Web tools.

via caskroom

$ brew cask install adium limechat skype

via Appstore

  • tweetbot
  • tweetdeck

Image

  • Adobe CreativeCloud

Medias

via caskroom

$ brew cask install spotify xld handbrake vlc

via Appstore

  • imovie

Productivity

via caskroom

$ brew cask install libreoffice calibre

via appstore

  • Wunderlist
  • Fantastical
  • ReadKit
  • Pages
  • Keynote
  • Glui
  • Cloudapp
  • Mindnode Pro
#! /bin/bash
BACKUP_DIR="/usr/local/var/backup"
MYSQL_USER="backup"
MYSQL_PASSWORD="backup"
MYSQL=/usr/local/bin/mysql
MYSQLDUMP=/usr/local/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment