rails.plugin.zsh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. function _rails_command () {
  2. if [ -e "bin/stubs/rails" ]; then
  3. bin/stubs/rails $@
  4. elif [ -e "bin/rails" ]; then
  5. bin/rails $@
  6. elif [ -e "script/rails" ]; then
  7. ruby script/rails $@
  8. elif [ -e "script/server" ]; then
  9. ruby script/$@
  10. else
  11. command rails $@
  12. fi
  13. }
  14. function _rake_command () {
  15. if [ -e "bin/stubs/rake" ]; then
  16. bin/stubs/rake $@
  17. elif [ -e "bin/rake" ]; then
  18. bin/rake $@
  19. elif type bundle &> /dev/null && [ -e "Gemfile" ]; then
  20. bundle exec rake $@
  21. else
  22. command rake $@
  23. fi
  24. }
  25. alias rails='_rails_command'
  26. compdef _rails_command=rails
  27. alias rake='_rake_command'
  28. compdef _rake_command=rake
  29. alias devlog='tail -f log/development.log'
  30. alias prodlog='tail -f log/production.log'
  31. alias testlog='tail -f log/test.log'
  32. alias -g RED='RAILS_ENV=development'
  33. alias -g REP='RAILS_ENV=production'
  34. alias -g RET='RAILS_ENV=test'
  35. # Rails aliases
  36. alias rc='rails console'
  37. alias rcs='rails console --sandbox'
  38. alias rd='rails destroy'
  39. alias rdb='rails dbconsole'
  40. alias rg='rails generate'
  41. alias rgm='rails generate migration'
  42. alias rp='rails plugin'
  43. alias ru='rails runner'
  44. alias rs='rails server'
  45. alias rsd='rails server --debugger'
  46. alias rsp='rails server --port'
  47. # Rake aliases
  48. alias rdm='rake db:migrate'
  49. alias rdms='rake db:migrate:status'
  50. alias rdr='rake db:rollback'
  51. alias rdc='rake db:create'
  52. alias rds='rake db:seed'
  53. alias rdd='rake db:drop'
  54. alias rdrs='rake db:reset'
  55. alias rdtc='rake db:test:clone'
  56. alias rdtp='rake db:test:prepare'
  57. alias rdmtc='rake db:migrate db:test:clone'
  58. alias rdsl='rake db:schema:load'
  59. alias rlc='rake log:clear'
  60. alias rn='rake notes'
  61. alias rr='rake routes'
  62. alias rrg='rake routes | grep'
  63. alias rt='rake test'
  64. alias rmd='rake middleware'
  65. alias rsts='rake stats'
  66. # legacy stuff
  67. alias sstat='thin --stats "/thin/stats" start'
  68. alias sg='ruby script/generate'
  69. alias sd='ruby script/destroy'
  70. alias sp='ruby script/plugin'
  71. alias sr='ruby script/runner'
  72. alias ssp='ruby script/spec'
  73. alias sc='ruby script/console'
  74. alias sd='ruby script/server --debugger'
  75. function remote_console() {
  76. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  77. }