Mac ROR开发环境配置

为了导入数据库 调整了一个底层参数 给电脑调崩了 又要重新配置
特此记录配置文档

1.安装homebrew https://brew.sh/
2.安装pgsql

1
$ brew install  postgresql

3.安装bundle

1
$ gem install bundler

4.安装rbenv

1
$ brew install rbenv

5.安装rails

1
$ sudo gem install rails

6.生成ssh key

1
$ ssh-keygen

查看ssh key

1
$ cat ~/.ssh/id_rsa.pub

应用ssh key

1
ssh-add ~/.ssh/id_rsa

7.配置bash profile

1
$ sudo vim .bash_profile

文件内容: export PATH=/usr/local/bin:$PATH
使其生效

1
$ source .bash_profile

8.安装redis
在这下载 https://redis.io/
将下载下来的包解压后放到/usr/local
进到对应文件夹

1
$ make install

参考
9.配置 vim
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
配置 .vimrc 下载vimrc
:PlunginInstall

用了一段时间发现 console 跟irb 里不能输入中文
又折腾了好久 其实就是没有安装readline

1
2
3
$ brew install readline 
$ rbenv uninstall 2.3.7
$ CONFIGURE_OPTS="--with-readline-dir=/usr/local/Cellar/readline/8.0.0" rbenv install 2.3.7

.bash_profile 里要配置
eval “$(rbenv init -)”
$ rbenv shell 2.3.7

ps:vimrc 参考
filetype on
set langmenu=none
set fileencodings=utf-8
set fileencoding=utf-8
set encoding=utf8

set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set number
set autoindent
set hlsearch
set incsearch
set encoding=utf-8
“ highlight Normal ctermfg=white ctermbg=cyan
set nowrap
syntax enable

let g:proj_window_width=5
set laststatus=2

map :FufFile
map :MRU
map :Rmodel
map :Rcontroller
map :Runit
map :Rfunctional
map :Rhelper
map :Rview
map :ZoomWin

“ Strip trailing whitespace
function! StripTrailingWhitespaces()
“ Preparation: save last search, and cursor position.
let _s=@/
let l = line(“.”)
let c = col(“.”)
“ Do the business:
%s/\s+$//e
“ Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
autocmd BufWritePre * :call StripTrailingWhitespaces()

“ match Todo /\s+$/
filetype plugin on
let mapleader = “,”

“ THE VIM OUTLINER (TVO)
“ defaults:
let otl_install_menu=1
let no_otl_maps=0
let no_otl_insert_maps=0

“ overrides:
let otl_bold_headers=0
let otl_use_thlnk=0

“ au BufWinLeave *.otl mkview
“ au BufWinEnter *.otl silent loadview
let maplocalleader = “,”

“”Only do this part when compiled with support for autocommands.
“if has(“autocmd”)
“ autocmd Filetype java setlocal omnifunc=javacomplete#Complete
“endif

set nocompatible “ be iMproved
filetype off “ required!

“ ============== Vundle part =================
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()

“ let Vundle manage Vundle
“ required!
Plugin ‘gmarik/vundle’

“ My Bundles here:

“ original repos on github
Plugin ‘tpope/vim-fugitive’
Plugin ‘Lokaltog/vim-easymotion’
“Plugin ‘rstacruz/sparkup’, {‘rtp’: ‘vim/‘}
Plugin ‘tpope/vim-rails.git’
Plugin ‘bumaociyuan/vim-matchit.git’
Plugin ‘ecomba/vim-ruby-refactoring.git’

“ vim-scripts repos
Plugin ‘L9’
Plugin ‘FuzzyFinder’

Plugin ‘git://git.wincent.com/command-t.git’
“Plugin ‘snipMate’
“Plugin ‘snipmate-snippets’
“Plugin ‘Jasmine-snippets-for-snipMate’
Plugin ‘YankRing.vim’
Plugin ‘The-NERD-Commenter’
Plugin ‘The-NERD-tree’
Plugin ‘kchmck/vim-coffee-script’

colorscheme monokai
set background=light
set background=dark
Plugin ‘mru.vim’
Plugin ‘greplace.vim’
call vundle#end()

filetype plugin indent on “ required!

“ Brief help
“ :PluginList - list configured bundles
“ :PluginInstall(!) - install(update) bundles
“ :PluginSearch(!) foo - search(or refresh cache first) for foo
“ :PluginClean(!) - confirm(or auto-approve) removal of unused bundles

“ see :h vundle for more details or wiki for FAQ
“ NOTE: comments after Plugin command are not allowed..

map f
map a :YRShow
map t :NERDTree
map q :q
map f :Rfixture
map rj :Rjavascript

“autocmd BufWritePost,FileWritePost .coffee :silent !coffee –compile –join appstore/static/javascripts/angular/controllers.js appstore/static/javascripts/angular/controllers.coffee appstore/static/javascripts/angular/tabs/coffee appstore/static/javascripts/angular/applications/coffee appstore/static/javascripts/angular/users/coffee appstore/static/javascripts/angular/commons/*coffee
“autocmd BufWritePost,FileWritePost *.coffee :silent !coffee –compile appstore/static/javascripts/angular/app.coffee appstore/static/javascripts/angular/directives.coffee appstore/static/javascripts/angular/filters.coffee appstore/static/javascripts/angular/services.coffee

“autocmd BufWritePost,FileWritePost .coffee :silent !coffee –compile –join tvboxcms/static/javascripts/angular/controllers.js tvboxcms/static/javascripts/angular/controllers.coffee tvboxcms/static/javascripts/angular/tabs/coffee tvboxcms/static/javascripts/angular/applications/coffee tvboxcms/static/javascripts/angular/users/coffee tvboxcms/static/javascripts/angular/commons/*coffee
“autocmd BufWritePost,FileWritePost *.coffee :silent !coffee –compile tvboxcms/static/javascripts/angular/app.coffee tvboxcms/static/javascripts/angular/directives.coffee tvboxcms/static/javascripts/angular/filters.coffee tvboxcms/static/javascripts/angular/services.coffee

“autocmd BufWritePost,FileWritePost .coffee :silent !coffee –compile –join m-cms-preview/static/javascripts/angular/controllers.js m-cms-preview/static/javascripts/angular/controllers.coffee m-cms-preview/static/javascripts/angular/tabs/coffee m-cms-preview/static/javascripts/angular/applications/coffee m-cms-preview/static/javascripts/angular/users/coffee m-cms-preview/static/javascripts/angular/commons/*coffee
“autocmd BufWritePost,FileWritePost *.coffee :silent !coffee –compile m-cms-preview/static/javascripts/angular/app.coffee m-cms-preview/static/javascripts/angular/directives.coffee m-cms-preview/static/javascripts/angular/filters.coffee m-cms-preview/static/javascripts/angular/services.coffee