rails.plugin.zsh 1.96 KB
Newer Older
1
function _rails_command () {
LFDM's avatar
LFDM committed
2
3
  if [ -e "bin/rails" ]; then
    bin/rails $@
4
5
  elif [ -e "script/rails" ]; then
    ruby script/rails $@
LFDM's avatar
LFDM committed
6
7
  elif [ -e "script/server" ]; then
    ruby script/$@
8
  else
9
    command rails $@
10
11
12
13
14
15
  fi
}

function _rake_command () {
  if [ -e "bin/rake" ]; then
    bin/rake $@
Satoshi Ohmori's avatar
Satoshi Ohmori committed
16
17
  elif type bundle &> /dev/null && [ -e "Gemfile" ]; then
    bundle exec rake $@
18
  else
19
    command rake $@
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  fi
}

alias rails='_rails_command'
compdef _rails_command=rails

alias rake='_rake_command'
compdef _rake_command=rake

alias devlog='tail -f log/development.log'
alias prodlog='tail -f log/production.log'
alias testlog='tail -f log/test.log'

alias -g RED='RAILS_ENV=development'
alias -g REP='RAILS_ENV=production'
alias -g RET='RAILS_ENV=test'

# Rails aliases
alias rc='rails console'
39
alias rcs='rails console --sandbox'
40
41
42
43
44
45
46
47
alias rd='rails destroy'
alias rdb='rails dbconsole'
alias rg='rails generate'
alias rgm='rails generate migration'
alias rp='rails plugin'
alias ru='rails runner'
alias rs='rails server'
alias rsd='rails server --debugger'
48
alias rsp='rails server --port'
49
50
51

# Rake aliases
alias rdm='rake db:migrate'
52
alias rdms='rake db:migrate:status'
53
54
55
56
alias rdr='rake db:rollback'
alias rdc='rake db:create'
alias rds='rake db:seed'
alias rdd='rake db:drop'
57
alias rdrs='rake db:reset'
58
59
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
60
alias rdmtc='rake db:migrate db:test:clone'
61
alias rdsl='rake db:schema:load'
62
63
64
alias rlc='rake log:clear'
alias rn='rake notes'
alias rr='rake routes'
65
alias rrg='rake routes | grep'
Headless's avatar
Headless committed
66
alias rt='rake test'
Gustavo Villa's avatar
Gustavo Villa committed
67
alias rmd='rake middleware'
Gustavo Villa's avatar
Gustavo Villa committed
68
alias rsts='rake stats'
69
70

# legacy stuff
71
alias sstat='thin --stats "/thin/stats" start'
72
73
74
alias sg='ruby script/generate'
alias sd='ruby script/destroy'
alias sp='ruby script/plugin'
Godwin Ko's avatar
Godwin Ko committed
75
alias sr='ruby script/runner'
76
77
78
alias ssp='ruby script/spec'
alias sc='ruby script/console'
alias sd='ruby script/server --debugger'
79

80
81
82
function remote_console() {
  /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
}