/macbook-bootstrap

Guide on how to setup productive development environment on macOS

Primary LanguageShell

Setup macOS for Software Development

This is my personal process setting up productive development environment on a fresh macOS. The guide below outlines the steps needed to install Command Line Tools, brew, update integrated shell tools, install zsh and customise it with the truly awesome zsh framework oh-my-zsh, install popular software for development, as well as everyday programs.

Finally, I have added my personal .gitconfig file with handy shortcuts and tools to support GitHub Flow workflow. It is meant to be forked, customised with your personal software list and ran.

All steps are automated with a a bootstrap.sh script that does that with few prompts to confirm each step.

How to use this repository

  1. Fork this repository and clone your fork.
  2. Customise Brewfile with your favorite list of programs you want installed, especially the cask part.
  3. If you don't want zsh, remove the steps in bootstrap.sh (or just enter n when prompted on the wizard).
  4. Run ./bootstrap.sh.
  5. Customize your ~/.zshrc file with theme (default is nice, but my favorite is "pygmalion") and plugins.

What does it do

First things first, get Xcode installed. Open Terminal and write:

xcode-select --install

Next, let's install brew, it makes it easy to install and manage basically every piece of software on your Mac.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor # to verify everything went smoothly
brew update

Cask is used to install 3rd party software (like Java, Google Chrome, IntelliJ IDEA and thousands of others). As of December 2015, cask comes bundled with Homebrew so you can directly try to do brew cask search iterm, see that the actual package name is iterm2 and install it with brew cask install iterm2.

Now that Brew is installed, we can install everything. This is my list of favorite packages. Customize it to your taste.

brew install zsh-completion # autocomplete in zsh (tabbing) for many tools
brew install gcc # this will take a while...
brew install git # although git comes with OS X, this way we get the latest version
brew install mtr # network diagnostic tool, useful when somebody asks "did the internet just stop?"
brew install tig # ncurses based UI for git, just tig in a repo
brew install fpp # facebook path picker, do a `git status | fpp` to see what it can do
brew install nmap # network security scanner
brew install shellcheck # shell script analyzer
brew install wget
brew install htop
brew install nano
brew install make

# more recent versions of popular programming language environments
brew install php
brew install node
brew install python
brew install ruby

# Cask installs third party applications
brew cask install visual-studio-code # open source text editor, has cool VCS features
brew cask install caffeine # keeps your Mac awake when you want to
brew cask install flux # adjusts the color temperature of your monitor to ease it on your eyes
brew cask install java # includes JDK
brew cask install iterm2 # great terminal replacement
brew cask install sourcetree # Great git GUI
brew cask install spectacle # Easy window management

# Opinionated
brew cask install google-chrome
brew cask install vagrant # Great to manage development environments (requires VM software)
brew cask install virtualbox # Virtual Machines
brew cask install spotify
brew cask install dropbox
brew cask install slack

Many Mac utils are not GNU compatible and might cause headaches for users accustomed to Linux shells. We can fix that.

brew install coreutils findutils bash grep # gnu core utils instead of the old and weird ones shipped with MacOS

However coreutils are installed with g prefix by default. We will prepend them to our path later (when we install a better shell) so we don't have to use gls instead of ls for example. If this is too much of a hassle to type every time, you can add a "gnubin" directory to your PATH and just call GNU ls with ls. You will need to add the following to your ~/.zshrc (or ~/.bash_profile in case you stick with bash):

echo 'PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"' >> ~/.zshrc

Run Windows applications on OS X

If you want to be able to run Windows applications under your Mac, you can do so with wine. However, it requires XQuartz.

brew cask install xquartz # Needed for wine, it will take ages to install, be patient

Now that you have xquartz, you can install wine.

brew install wine # run windows programs on your Mac

I'm a huge fan of zsh as a better alternative to bash. After we activate zsh, we install oh-my-zsh, which will let us customize our shell with some neat completion plugins and git bonuses.

brew install zsh zsh-completions
# Activate it as your new default shell. If you get an "chsh: Operation is not supported..." error, read below.
chsh -s $(which zsh)
# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

chsh: Operation is not supported ...

If you happen to have a network account on Open Directory server, attempting to switch your shell with chsh will give you a message like:

chsh: Operation is not supported by the directory node.  Operation is not supported by the directory node.
chsh: no changes made

There is a workaround - we can activate zsh everytime we open a shell.

echo 'export SHELL=$(which zsh)' >> ~/.bash_profile
echo 'exec $(which zsh) -l' >> ~/.bash_profile