rails.plugin.zsh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 rrg='rails routes | grep'
  66. alias rs='rails server'
  67. alias rsb='rails server --bind'
  68. alias rsd='rails server --debugger'
  69. alias rsp='rails server --port'
  70. alias rsts='rails stats'
  71. alias rt='rails test'
  72. alias ru='rails runner'
  73. # Foreman aliases
  74. alias fmns='foreman start'
  75. # Rake aliases
  76. alias rkdc='rake db:create'
  77. alias rkdd='rake db:drop'
  78. alias rkdm='rake db:migrate'
  79. alias rkdmd='rake db:migrate:down'
  80. alias rkdmr='rake db:migrate:redo'
  81. alias rkdms='rake db:migrate:status'
  82. alias rkdmtc='rake db:migrate db:test:clone'
  83. alias rkdmu='rake db:migrate:up'
  84. alias rkdr='rake db:rollback'
  85. alias rkdrs='rake db:reset'
  86. alias rkds='rake db:seed'
  87. alias rkdsl='rake db:schema:load'
  88. alias rkdtc='rake db:test:clone'
  89. alias rkdtp='rake db:test:prepare'
  90. alias rklc='rake log:clear'
  91. alias rkmd='rake middleware'
  92. alias rkn='rake notes'
  93. alias rksts='rake stats'
  94. alias rkt='rake test'
  95. # legacy stuff
  96. alias sc='ruby script/console'
  97. alias sd='ruby script/destroy'
  98. alias sd='ruby script/server --debugger'
  99. alias sg='ruby script/generate'
  100. alias sp='ruby script/plugin'
  101. alias sr='ruby script/runner'
  102. alias ssp='ruby script/spec'
  103. alias sstat='thin --stats "/thin/stats" start'
  104. function remote_console() {
  105. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  106. }