1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-18 02:20:09 +00:00
ohmyzsh/plugins/rails/rails.plugin.zsh
Kartikey Tanna 7a8d89688d
Replce 'rake routes' task with 'rails rotues' (#9662)
* Replce 'rake routes' task with 'rails rotues'

Fixes https://github.com/ohmyzsh/ohmyzsh/issues/9661

* Modified 'rake routes|grep' to use rails
2021-02-20 22:24:21 -08:00

86 lines
2.1 KiB
Bash

function _rails_command () {
if [ -e "bin/stubs/rails" ]; then
bin/stubs/rails $@
elif [ -e "bin/rails" ]; then
bin/rails $@
elif [ -e "script/rails" ]; then
ruby script/rails $@
elif [ -e "script/server" ]; then
ruby script/$@
else
command rails $@
fi
}
function _rake_command () {
if [ -e "bin/stubs/rake" ]; then
bin/stubs/rake $@
elif [ -e "bin/rake" ]; then
bin/rake $@
elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
bundle exec rake $@
else
command rake $@
fi
}
alias rails='_rails_command'
compdef _rails_command=rails
alias rake='_rake_command'
compdef _rake_command=rake
alias devlog='tail -f log/development.log'
alias prodlog='tail -f log/production.log'
alias testlog='tail -f log/test.log'
alias -g RED='RAILS_ENV=development'
alias -g REP='RAILS_ENV=production'
alias -g RET='RAILS_ENV=test'
# Rails aliases
alias rc='rails console'
alias rcs='rails console --sandbox'
alias rd='rails destroy'
alias rdb='rails dbconsole'
alias rgen='rails generate'
alias rgm='rails generate migration'
alias rp='rails plugin'
alias rr='rails routes'
alias rrg='rails routes | grep'
alias ru='rails runner'
alias rs='rails server'
alias rsd='rails server --debugger'
alias rsp='rails server --port'
# Rake aliases
alias rdm='rake db:migrate'
alias rdms='rake db:migrate:status'
alias rdr='rake db:rollback'
alias rdc='rake db:create'
alias rds='rake db:seed'
alias rdd='rake db:drop'
alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone'
alias rdsl='rake db:schema:load'
alias rlc='rake log:clear'
alias rn='rake notes'
alias rt='rake test'
alias rmd='rake middleware'
alias rsts='rake stats'
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'
alias sg='ruby script/generate'
alias sd='ruby script/destroy'
alias sp='ruby script/plugin'
alias sr='ruby script/runner'
alias ssp='ruby script/spec'
alias sc='ruby script/console'
alias sd='ruby script/server --debugger'
function remote_console() {
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
}