rails.plugin.zsh 1.7 KB

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