Skip to content

Instantly share code, notes, and snippets.

@dehengxu
Forked from mcls/osx_setup.md
Last active February 20, 2019 05:20
Show Gist options
  • Save dehengxu/0b891e77d6994cb76d421e609ecc266d to your computer and use it in GitHub Desktop.
Save dehengxu/0b891e77d6994cb76d421e609ecc266d to your computer and use it in GitHub Desktop.
Setup mac for ruby dev

Setup new Mac from scratch

Re-create admin user

  1. Reboot with command + s
  2. Enter /sbin/mount -uw in Terminal
  3. rm var/db/.AppleSetupDone Remove cache data.
  4. Reboot again.

Install Xcode

Installing Xcode and the command line tools need to be done first because it installs gcc. https://developer.apple.com/xcode/features/

Homebrew

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

Note that Xcode is a pre-req for Homebrew.

http://brew.sh/

https://github.com/Homebrew/homebrew/wiki/Installation

Install common tools:

brew update
brew install git vim tmux postgresql mysql tree

HomeBrew tips:

Install specified version: https://www.jianshu.com/p/aadb54eac0a8 https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula

Disable update when install:

add `export HOMEBREW_NO_AUTO_UPDATE=false` to bash environment `~/.bashrc`

Installation speed up:

add `export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"` to `~/.bashrc` to use mirrors in China for speed.

Github API token:

add `export HOMEBREW_GITHUB_API_TOKEN="xxx150dd43bd584ce2b17cd513a086c0844605bae9"` to `~/.bashrc`

Set shell to ZSH and install oh-my-zsh

curl -L http://install.ohmyz.sh | sh

rvm

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

\curl -sSL https://get.rvm.io | bash -s stable

rbenv and ruby-build

https://github.com/rbenv/rbenv

https://github.com/sstephenson/rbenv

Install by homebrew :

brew update
brew install rbenv rbenv-gem-rehash ruby-build

# Install ruby 2.1.2
rbenv install 2.1.2
rbenv global 2.1.2
rbenv rehash

echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
gem update --system
gem install bundler rails --no-ri --no-rdoc

Manual install:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile # 这里可以是任何的终端环境配置文件
eval "$(rbenv init -)" # 必须要有双引号

Faster gem installs

For faster gem install tell rubygems to ignore ri and rdoc creating a ~/.gemrc with:

install: --no-ri --no-rdoc
update: --no-ri --no-rdoc

NVM

`curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`

`wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`

gem mirrors for china:

```
gem -a https://gems.ruby-china.com
gem -r https://rubygems.org
gem install bundler
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
```

node mirrors for china:

`cat registry=https://registry.npm.taobao.org/ > ~/.npmrc`

`npm install nrm`

c++ package manager

vcpkg contributed from Microsoft

`git clone https://github.com/Microsoft/vcpkg.git`

Pip

Config for China

~/.pip/pip.conf

```
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
```

sublime

Place plugin package whole folder under path: $HOME/Library/Application Support/Sublime Text 3/Packages/

plugins

[CmakeLists](https://github.com/zyxar/Sublime-CMakeLists.git)

[assembly support](https://github.com/foxostro/x86-assembly-textmate-bundle.git)

Apps

Ruby 工具

gem install cocoapods xcpretty synx

Alfred

Alfred is an award-winning productivity application for Mac OS X, which aims to save you time in searching your local computer and the web.

http://www.alfredapp.com/

Dash

Awesome documentation browser.

Dash gives your Mac instant offline access to 150+ API documentation sets.

https://itunes.apple.com/us/app/dash-docs-snippets/id458034879?mt=12

http://kapeli.com/dash

iTerm2

A nice alternative to Terminal.app.

http://www.iterm2.com/

Solarized color scheme

A nice color scheme.

http://ethanschoonover.com/solarized

Pow

Pow is a zero-config Rack server for Mac OS X.

curl get.pow.cx | sh

To get it to work with Apache check: https://github.com/37signals/pow/wiki/Running-Pow-with-Apache

http://pow.cx/

VLC

VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols.

http://www.videolan.org/vlc/index.html

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