rails.plugin.zsh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. elif type bundle &> /dev/null && [ -e "Gemfile" ]; then
  16. bundle exec rake $@
  17. else
  18. command rake $@
  19. fi
  20. }
  21. alias rails='_rails_command'
  22. compdef _rails_command=rails
  23. alias rake='_rake_command'
  24. compdef _rake_command=rake
  25. alias devlog='tail -f log/development.log'
  26. alias prodlog='tail -f log/production.log'
  27. alias testlog='tail -f log/test.log'
  28. alias -g RED='RAILS_ENV=development'
  29. alias -g REP='RAILS_ENV=production'
  30. alias -g RET='RAILS_ENV=test'
  31. # Rails aliases
  32. alias rc='rails console'
  33. alias rcs='rails console --sandbox'
  34. alias rd='rails destroy'
  35. alias rdb='rails dbconsole'
  36. alias rg='rails generate'
  37. alias rgm='rails generate migration'
  38. alias rp='rails plugin'
  39. alias ru='rails runner'
  40. alias rs='rails server'
  41. alias rsd='rails server --debugger'
  42. alias rsp='rails server --port'
  43. # Rake aliases
  44. alias rdm='rake db:migrate'
  45. alias rdms='rake db:migrate:status'
  46. alias rdr='rake db:rollback'
  47. alias rdc='rake db:create'
  48. alias rds='rake db:seed'
  49. alias rdd='rake db:drop'
  50. alias rdrs='rake db:reset'
  51. alias rdtc='rake db:test:clone'
  52. alias rdtp='rake db:test:prepare'
  53. alias rdmtc='rake db:migrate db:test:clone'
  54. alias rdsl='rake db:schema:load'
  55. alias rlc='rake log:clear'
  56. alias rn='rake notes'
  57. alias rr='rake routes'
  58. alias rrg='rake routes | grep'
  59. alias rt='rake test'
  60. alias rmd='rake middleware'
  61. alias rsts='rake stats'
  62. # legacy stuff
  63. alias sstat='thin --stats "/thin/stats" start'
  64. alias sg='ruby script/generate'
  65. alias sd='ruby script/destroy'
  66. alias sp='ruby script/plugin'
  67. alias sr='ruby script/runner'
  68. alias ssp='ruby script/spec'
  69. alias sc='ruby script/console'
  70. alias sd='ruby script/server --debugger'
  71. function remote_console() {
  72. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  73. }