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" ] || [ -e "gems.rb" ]); 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 rgen='rails generate'
  41. alias rgm='rails generate migration'
  42. alias rp='rails plugin'
  43. alias rr='rails routes'
  44. alias rrg='rails routes | grep'
  45. alias ru='rails runner'
  46. alias rs='rails server'
  47. alias rsd='rails server --debugger'
  48. alias rsp='rails server --port'
  49. # Rake aliases
  50. alias rdm='rake db:migrate'
  51. alias rdms='rake db:migrate:status'
  52. alias rdr='rake db:rollback'
  53. alias rdc='rake db:create'
  54. alias rds='rake db:seed'
  55. alias rdd='rake db:drop'
  56. alias rdrs='rake db:reset'
  57. alias rdtc='rake db:test:clone'
  58. alias rdtp='rake db:test:prepare'
  59. alias rdmtc='rake db:migrate db:test:clone'
  60. alias rdsl='rake db:schema:load'
  61. alias rlc='rake log:clear'
  62. alias rn='rake notes'
  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. }