rails.plugin.zsh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # rails command wrapper
  2. function _rails_command () {
  3. if [ -e "bin/stubs/rails" ]; then
  4. bin/stubs/rails $@
  5. elif [ -e "bin/rails" ]; then
  6. bin/rails $@
  7. elif [ -e "script/rails" ]; then
  8. ruby script/rails $@
  9. elif [ -e "script/server" ]; then
  10. ruby script/$@
  11. else
  12. command rails $@
  13. fi
  14. }
  15. alias rails='_rails_command'
  16. compdef _rails_command=rails
  17. # rake command wrapper
  18. function _rake_command () {
  19. if [ -e "bin/stubs/rake" ]; then
  20. bin/stubs/rake $@
  21. elif [ -e "bin/rake" ]; then
  22. bin/rake $@
  23. elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then
  24. bundle exec rake $@
  25. else
  26. command rake $@
  27. fi
  28. }
  29. alias rake='_rake_command'
  30. compdef _rake_command=rake
  31. # Log aliases
  32. alias devlog='tail -f log/development.log'
  33. alias prodlog='tail -f log/production.log'
  34. alias testlog='tail -f log/test.log'
  35. # Environment settings
  36. alias -g RED='RAILS_ENV=development'
  37. alias -g REP='RAILS_ENV=production'
  38. alias -g RET='RAILS_ENV=test'
  39. # Rails aliases
  40. alias rc='rails console'
  41. alias rcs='rails console --sandbox'
  42. alias rd='rails destroy'
  43. alias rdb='rails dbconsole'
  44. alias rdc='rails db:create'
  45. alias rdd='rails db:drop'
  46. alias rdm='rails db:migrate'
  47. alias rdmd='rails db:migrate:down'
  48. alias rdmr='rails db:migrate:redo'
  49. alias rdms='rails db:migrate:status'
  50. alias rdmtc='rails db:migrate db:test:clone'
  51. alias rdmu='rails db:migrate:up'
  52. alias rdr='rails db:rollback'
  53. alias rdrs='rails db:reset'
  54. alias rds='rails db:seed'
  55. alias rdsl='rails db:schema:load'
  56. alias rdtc='rails db:test:clone'
  57. alias rdtp='rails db:test:prepare'
  58. alias rgen='rails generate'
  59. alias rgm='rails generate migration'
  60. alias rlc='rails log:clear'
  61. alias rmd='rails middleware'
  62. alias rn='rails notes'
  63. alias rp='rails plugin'
  64. alias rr='rails routes'
  65. alias rrc='rails routes --controller'
  66. alias rre='rails routes --expanded'
  67. alias rrg='rails routes --grep'
  68. alias rru='rails routes --unused'
  69. alias rs='rails server'
  70. alias rsb='rails server --bind'
  71. alias rsd='rails server --debugger'
  72. alias rsp='rails server --port'
  73. alias rsts='rails stats'
  74. alias rt='rails test'
  75. alias rta='rails test:all'
  76. alias ru='rails runner'
  77. # Foreman aliases
  78. alias fmns='foreman start'
  79. # Rake aliases
  80. alias rkdc='rake db:create'
  81. alias rkdd='rake db:drop'
  82. alias rkdm='rake db:migrate'
  83. alias rkdmd='rake db:migrate:down'
  84. alias rkdmr='rake db:migrate:redo'
  85. alias rkdms='rake db:migrate:status'
  86. alias rkdmtc='rake db:migrate db:test:clone'
  87. alias rkdmu='rake db:migrate:up'
  88. alias rkdr='rake db:rollback'
  89. alias rkdrs='rake db:reset'
  90. alias rkds='rake db:seed'
  91. alias rkdsl='rake db:schema:load'
  92. alias rkdtc='rake db:test:clone'
  93. alias rkdtp='rake db:test:prepare'
  94. alias rklc='rake log:clear'
  95. alias rkmd='rake middleware'
  96. alias rkn='rake notes'
  97. alias rksts='rake stats'
  98. alias rkt='rake test'
  99. # legacy stuff
  100. alias sc='ruby script/console'
  101. alias sd='ruby script/destroy'
  102. alias sd='ruby script/server --debugger'
  103. alias sg='ruby script/generate'
  104. alias sp='ruby script/plugin'
  105. alias sr='ruby script/runner'
  106. alias ssp='ruby script/spec'
  107. alias sstat='thin --stats "/thin/stats" start'
  108. function remote_console() {
  109. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  110. }