rails.plugin.zsh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 rdtc='rake db:test:clone'
  47. alias rdtp='rake db:test:prepare'
  48. alias rdmtc='rake db:migrate db:test:clone'
  49. alias rlc='rake log:clear'
  50. alias rn='rake notes'
  51. alias rr='rake routes'
  52. # legacy stuff
  53. alias ss='thin --stats "/thin/stats" start'
  54. alias sg='ruby script/generate'
  55. alias sd='ruby script/destroy'
  56. alias sp='ruby script/plugin'
  57. alias sr='ruby script/runner'
  58. alias ssp='ruby script/spec'
  59. alias sc='ruby script/console'
  60. alias sd='ruby script/server --debugger'
  61. function remote_console() {
  62. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  63. }