rails.plugin.zsh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. alias rsp='rails server --port'
  40. # Rake aliases
  41. alias rdm='rake db:migrate'
  42. alias rdms='rake db:migrate:status'
  43. alias rdr='rake db:rollback'
  44. alias rdc='rake db:create'
  45. alias rds='rake db:seed'
  46. alias rdd='rake db:drop'
  47. alias rdrs='rake db:reset'
  48. alias rdtc='rake db:test:clone'
  49. alias rdtp='rake db:test:prepare'
  50. alias rdmtc='rake db:migrate db:test:clone'
  51. alias rlc='rake log:clear'
  52. alias rn='rake notes'
  53. alias rr='rake routes'
  54. alias rrg='rake routes | grep'
  55. alias rt='rake test'
  56. alias rmd='rake middleware'
  57. alias rsts='rake stats'
  58. # legacy stuff
  59. alias sstat='thin --stats "/thin/stats" start'
  60. alias sg='ruby script/generate'
  61. alias sd='ruby script/destroy'
  62. alias sp='ruby script/plugin'
  63. alias sr='ruby script/runner'
  64. alias ssp='ruby script/spec'
  65. alias sc='ruby script/console'
  66. alias sd='ruby script/server --debugger'
  67. function remote_console() {
  68. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  69. }