rails.plugin.zsh 2.2 KB

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