rails.plugin.zsh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. rails $@
  10. fi
  11. }
  12. function _rake_command () {
  13. if [ -e "bin/rake" ]; then
  14. bin/rake $@
  15. else
  16. 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 rdr='rake db:rollback'
  42. alias rdc='rake db:create'
  43. alias rds='rake db:seed'
  44. alias rdd='rake db:drop'
  45. alias rdtc='rake db:test:clone'
  46. alias rdtp='rake db:test:prepare'
  47. alias rdmtc='rake db:migrate db:test:clone'
  48. alias rlc='rake log:clear'
  49. alias rn='rake notes'
  50. alias rr='rake routes'
  51. # legacy stuff
  52. alias ss='thin --stats "/thin/stats" start'
  53. alias sg='ruby script/generate'
  54. alias sd='ruby script/destroy'
  55. alias sp='ruby script/plugin'
  56. alias sr='ruby script/runner'
  57. alias ssp='ruby script/spec'
  58. alias sc='ruby script/console'
  59. alias sd='ruby script/server --debugger'
  60. function remote_console() {
  61. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  62. }