Skip to content

Instantly share code, notes, and snippets.

@ssjr
Last active June 17, 2022 14:10
Show Gist options
  • Save ssjr/5970762 to your computer and use it in GitHub Desktop.
Save ssjr/5970762 to your computer and use it in GitHub Desktop.
My setup for Ruby on Rails with Mac OS X

My initial setup for Ruby on Rails development

Note: I'm using Mac OS X Lion (10.7.5)

All links, commands and order to install

  1. Download Xcode
  2. Open Xcode, Xcode (menu) > Preferences... > Downloads. Install Command Line Tools
  3. Install Homebrew
  • ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  1. Download and install iTerm
  2. Download oh-my-zsh
  • curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
  1. Download Heroku Toolbelt
  2. Git config
  • git config --global user.email "my@email.com"
  • git config --global user.name "my name"
  • git config --global color.ui auto
  • git config --global help.autocorrect 1
  • git config --global core.editor /usr/bin/vim
  • git config --global core.excludesfile ~/.gitignore_global
  1. brew install git
  2. brew install rbenv
  3. brew install ruby-build
  4. rbenv install 2.1.1
  5. rbenv global 2.1.1
  6. brew install ctags
  7. brew install macvim
  8. git clone git://github.com/akitaonrails/vimfiles.git ~/.vim
  9. cd ~/.vim
  10. git submodule update --init
  11. echo "source ~/.vim/vimrc" > ~/.vimrc
  12. echo "source ~/.vim/gvimrc" > ~/.gvimrc
  13. git submodule foreach git pull origin master
  14. cd ~/
  15. mkdir Code
  16. touch .gitignore_global
  17. brew install openssl
  18. sudo gem install bundler
  19. sudo gem install rails
  20. Download Postgres.app
  • On Postgres.app icon, disable Open Documentation at Start
  1. sudo gem install awesome_print
  2. sudo gem install pry

Some files

~/.zshrc

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"

# Uncomment to change how often before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment following line if you want to disable command autocorrection
# DISABLE_CORRECTION="true"

# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"

# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git heroku)

source $ZSH/oh-my-zsh.sh

alias quem_foi_o_filho_da_puta="git blame"
alias start="bundle exec rake db:drop db:create db:migrate db:seed db:test:prepare db:test:load && rails s"
alias rdbr="bundle exec rake db:migrate; start"

# Customize to your needs...
# export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export PATH=/usr/local/bin:/usr/bin:$PATH:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin

eval "$(rbenv init -)"

function update-vim(){
  local back_directory=$PWD
  echo -e "\e[32mStarting to update vim plugins!\033[0m"
  echo -e "\e[32mYou are in $back_directory and will back after update all plugins\033[0m"
  echo -e "\e[32mNow changing directory to $HOME/.vim and starting update plugins\033[0m"
  echo -e "\e[32m---------------------------------\033[0m\n"
  cd ~/.vim
  git pull origin master $1
  git submodule foreach git pull origin master $1
  echo -e "\e[32m\n---------------------------------\033[0m\n"
  echo -e "\e[32mDone! All plugins are updated\033[0m"
  echo -e "\e[32mNow changing back for $back_directory\033[0m"
  cd $back_directory
}

function update-dev(){
  local this_directory=$PWD
  echo -e "\e[32m\n-----------------------------------------------\033[0m"
  echo -e "\e[32m|   Starting to update rails development env  |\033[0m"
  echo -e "\e[32m-----------------------------------------------\033[0m"
  echo -e "\e[32m|       This operation may take a while       |\033[0m"
  echo -e "\e[32m|              Take a coffee :)               |\033[0m"
  echo -e "\e[32m-----------------------------------------------\033[0m\n\n"
  echo -e "\e[32mYou are in $this_directory. And will back here\033[0m"
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mUpdating oh-my-zsh\033[0m"
  cd $ZSH
  git pull origin master -q
  echo -e "\e[32mZSH updated\033[0m"
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mRunning gem update --system\033[0m"
  sudo gem update --system
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mRunning brew update & upgrade\033[0m"
  brew update && brew upgrade --all
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mRunning brew doctor\033[0m"
  brew doctor
  echo -e "\e[32mBrew updated\033[0m"
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mNow will update vim plugins\033[0m"
  cd $this_directory
  update-vim -q
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mNow will cleanup the gems\033[0m"
  gem cleanup
  echo -e "\e[32m---------------------------------\033[0m"
  echo -e "\e[32mNow you are back to $this_directory and can work :D\033[0m"
}

function clear-swp(){
  # find . -regex ".*\.s[abcdefghijklmnopqrstuv][a-z]" -type f
  # find . -regex ".*\.s[abcdefghijklmnopqrstuv][a-z]" -type f -delete
  find . -regex ".*\.sw[abcdeghijklmnop]" -type f
  # find . -regex ".*\.sw[abcdeghijklmnop]" -type f -delete
}

~/.gitignore_global

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# Vim files

# not ignore .swf and .swz files (flash)
*.s[a-v][a-z]
*.sw[a-e]
*.sw[g-y]
*.un~
Session.vim
.netrwhist
*~

# rbenv
.ruby-version

~/.vim/vimrc

Replace this

    if has("gui_gnome")
        set term=gnome-256color
        colorscheme molokai
        set guifont=Monospace\ Bold\ 12
    endif

    if has("gui_mac") || has("gui_macvim")
        set guifont=Menlo:h12
        set transparency=7
    endif

    if has("gui_win32") || has("gui_win32s")
        set guifont=Consolas:h12
        set enc=utf-8
    endif

with

    if has("gui_gnome")
        set term=gnome-256color
        colorscheme molokai
        set guifont=Monospace\ Bold\ 18
    endif

    if has("gui_mac") || has("gui_macvim")
        set guifont=Menlo:h18
        set transparency=7
    endif

    if has("gui_win32") || has("gui_win32s")
        set guifont=Consolas:h18
        set enc=utf-8
    endif

Add (end of file)

set encoding=utf-8
set relativenumber

~/.irbrc

require 'irb/completion'

require "awesome_print"
AwesomePrint.irb!

~/.pryrc

require "awesome_print"
AwesomePrint.pry!

~/.gitconfig

[color]
    ui = auto
    editor = /usr/bin/vim
    interactive = auto
[user]
    name = My Name
    email = my@email.com
[core]
    excludesfile = /Users/myusername/.gitignore_global
# [color "diff"]
#     old = red reverse
#     new = green reverse
[alias]
    d = diff --color-words
    report = "log --author=Name --since='2 sunday ago' --until='1 sunday ago' --format='\"%ci\",\"%s\"' --no-merges"

That's all folks

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