Effective Procedures to Setup new Mac Sierra For Rubyist

This article describes effective procedures for Rubyists to setup new Mac OS Sierra.


Install some applications

For development

For productivity

Homebrew

Before any installation, you should approve Xcode license agreement by the following command:

1
$ sudo xcodebuild -license

You should execute the following command to install Homebrew:

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

If you are asked about Xcode Command line tool while installing with Homebrew, please install it.

Oh-my-zsh

If you want to use a coftable Zsh customized by the community, let’s install
robbyrussell/oh-my-zsh.

1
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Git

You should install Git command line tool:

1
2
3
4
$ brew install git
$ git config --global user.name "USER_NAME"
$ git config --global user.email [email protected]
$ git config --global tag.sort version:refname

After installing Git, we recommend to set global .gitignore:

1
2
3
4
5
6
7
8
# generator about .gitignore
$ brew install gibo
# Set some unnecessary files of JetBrains and Mac to .gitignore
$ gibo JetBrains OSX > ~/.gitignore
# Set the .gitignore to set git global setting
$ git config --global --add core.excludesfile "$HOME/.gitignore"

You should set basic passwords to skip filling password by vi ~/.netrc:

1
2
3
machine github.com
login USERNAME
password PASSWORD

In addition, please add a alias git push-f to vi ~/.gitconfig

1
2
[alias]
push-f = push --force-with-lease

autojump

If you want to fill a path more quickly,
wting/autojump is one of the greatest solutions.

1
$ brew install autojump

After installing, set the following setting by vi ~/.zshrc

1
2
# autojump
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

After the setting, execute the following command to reflect the setting:

1
$ source ~/.zshrc

Font Ricty

Ricty is a fonts for programming, if you want to try it, please set the following command:

1
2
3
4
5
6
7
8
9
10
11
12
# Installing Ricty
$ brew install automake
$ brew tap sanemat/font
$ brew install Caskroom/cask/xquartz
$ brew install ricty
# Copy generated font information
$ cp -f /usr/local/opt/ricty/share/fonts/Ricty*.ttf ~/Library/Fonts/
$ fc-cache -vf
# Setting about anti-alias
$ defaults -currentHost write -globalDomain AppleFontSmoothing -int 2

rbenv

To avoid installing unnecessary documents, add the following setting vim ~/.gemrc:

1
2
install: --no-document
update: --no-document

After the above setting, let’s install the following rbenv and Ruby-build:

1
2
3
4
5
6
7
8
# Installing rbenv / ruby-build
$ brew install rbenv ruby-build
# Setting to installing gems when introducing new version
$ git clone https://github.com/sstephenson/rbenv-default-gems.git ~/.rbenv/plugins/rbenv-default-gems
# Setting default install gems
$ echo 'bundler\nrails\npg\npry' > ~/.rbenv/default-gems

Edit the following setting by vi ~/.zshrc:

1
2
3
4
# rbenv
[[ -d ~/.rbenv ]] && \
export PATH=${HOME}/.rbenv/bin:${PATH} && \
eval "$(rbenv init -)"

The setting is reflected by the following command:

1
$ source ~/.zshrc

Install Ruby by rbenv:

1
2
3
4
5
6
# show list of ruby versions which is able to install
$ rbenv install -l
# Install latest ruby version(e.g. 2.4.0)
$ rbenv install 2.4.0
$ rbenv global 2.4.0

PostgreSQL

1
2
3
4
5
6
7
8
# Install PostgreSQL
$ brew install postgresql
# To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*plist ~/Library/LaunchAgents
# Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Docker (Optional)

Please set alias to vi .zshrc:

1
2
3
4
# Docker
alias d='docker'
alias dc='docker-compose'
alias dm='docker-machine'

After setting, reflect the upper settings:

1
source ~/.zshrc

Java (Optional)

Download JDK from Java SE - Downloads / Oracle and install it.

After install JDK, you should install Maven & gradle too.

1
2
brew install homebrew/versions/maven32
brew install gradle

After that, please write the bellow code in .zshrc or .bashrc:

1
2
# Java
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Please refer to java - Intellij Idea: Importing Gradle project - getting JAVA_HOME not defined yet - Stack Overflow and set the SDK at the first start of IntelliJ Idea.

Tips

Change function keys

1
Application > System Preferences > Keybord > Use all F1, F2, etc...

Change shortcut to change active window

1
Application > System Preferences > Keybord > Shortcut > Keybord > Move focus next window

Change computer name

1
Application > System Preferences > Sharing > Computer Name

Change cursor speed

1
Application > System Preferences > Mouse > Tracking Speed