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

function _rake_command () {
16
17
18
  if [ -e "bin/stubs/rake" ]; then
    bin/stubs/rake $@
  elif [ -e "bin/rake" ]; then
19
    bin/rake $@
20
  elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
Satoshi Ohmori's avatar
Satoshi Ohmori committed
21
    bundle exec rake $@
22
  else
23
    command rake $@
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  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'
43
alias rcs='rails console --sandbox'
44
45
alias rd='rails destroy'
alias rdb='rails dbconsole'
46
alias rgen='rails generate'
47
48
alias rgm='rails generate migration'
alias rp='rails plugin'
49
50
alias rr='rails routes'
alias rrg='rails routes | grep'
51
52
53
alias ru='rails runner'
alias rs='rails server'
alias rsd='rails server --debugger'
54
alias rsp='rails server --port'
55
alias rsb='rails server --bind'
56
57
58

# Rake aliases
alias rdm='rake db:migrate'
59
alias rdmd='rake db:migrate:down'
60
alias rdms='rake db:migrate:status'
61
alias rdmu='rake db:migrate:up'
62
63
64
65
alias rdr='rake db:rollback'
alias rdc='rake db:create'
alias rds='rake db:seed'
alias rdd='rake db:drop'
66
alias rdrs='rake db:reset'
67
68
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
69
alias rdmtc='rake db:migrate db:test:clone'
70
alias rdsl='rake db:schema:load'
71
72
alias rlc='rake log:clear'
alias rn='rake notes'
Headless's avatar
Headless committed
73
alias rt='rake test'
Gustavo Villa's avatar
Gustavo Villa committed
74
alias rmd='rake middleware'
Gustavo Villa's avatar
Gustavo Villa committed
75
alias rsts='rake stats'
76
77

# legacy stuff
78
alias sstat='thin --stats "/thin/stats" start'
79
80
81
alias sg='ruby script/generate'
alias sd='ruby script/destroy'
alias sp='ruby script/plugin'
Godwin Ko's avatar
Godwin Ko committed
82
alias sr='ruby script/runner'
83
84
85
alias ssp='ruby script/spec'
alias sc='ruby script/console'
alias sd='ruby script/server --debugger'
86

87
88
89
function remote_console() {
  /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
}