From 9b37fcba5e350d049d4bbf145672cecd37356c23 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Tue, 19 Nov 2013 17:05:48 +0100 Subject: unified and improved Rails plugin --- plugins/rails/_rails | 63 +++++++++++++++++++++++++++++++++++++ plugins/rails/rails.plugin.zsh | 68 ++++++++++++++++++++++++++++++++++------ plugins/rails3/_rails3 | 56 --------------------------------- plugins/rails3/rails3.plugin.zsh | 32 ------------------- plugins/rails4/rails4.plugin.zsh | 32 ------------------- 5 files changed, 122 insertions(+), 129 deletions(-) create mode 100644 plugins/rails/_rails delete mode 100644 plugins/rails3/_rails3 delete mode 100644 plugins/rails3/rails3.plugin.zsh delete mode 100644 plugins/rails4/rails4.plugin.zsh diff --git a/plugins/rails/_rails b/plugins/rails/_rails new file mode 100644 index 000000000..96f57ce64 --- /dev/null +++ b/plugins/rails/_rails @@ -0,0 +1,63 @@ +#compdef rails +#autoload + +local -a _1st_arguments +_1st_arguments=( + 'generate:Generate new code (short-cut alias: "g")' + 'console:Start the Rails console (short-cut alias: "c")' + 'server:Start the Rails server (short-cut alias: "s")' + 'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")' + 'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"' + 'application:Generate the Rails application code' + 'destroy:Undo code generated with "generate"' + + 'benchmarker:See how fast a piece of code runs' + 'profiler:Get profile information from a piece of code' + 'plugin:Install a plugin' + + 'plugin new:Generates skeleton for developing a Rails plugin' + 'runner:Run a piece of code in the application environment (short-cut alias: "r")' +) + +_rails_generate_arguments() { + generate_arguments=( + assets + controller + decorator + generator + helper + integration_test + mailer + migration + model + observer + performance_test + plugin + resource + scaffold + scaffold_controller + session_migration + stylesheets + task + ) +} + + +_arguments \ + '(--version)--version[show version]' \ + '(--help)--help[show help]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "rails subcommand" _1st_arguments + return +fi + +case "$words[1]" in + g|generate) + _rails_generate_arguments + _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;; + d|destroy) + _rails_generate_arguments + _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;; +esac diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index dd8b174b2..23d15a9a1 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -1,20 +1,70 @@ +function _rails_command () { + if [ -e "script/server" ]; then + ruby script/$@ + elif [ -e "script/rails" ]; then + ruby script/rails $@ + elif [ -e "bin/rails" ]; then + bin/rails $@ + else + rails $@ + fi +} + +function _rake_command () { + if [ -e "bin/rake" ]; then + bin/rake $@ + else + 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 rd='rails destroy' +alias rdb='rails dbconsole' +alias rg='rails generate' +alias rgm='rails generate migration' +alias rp='rails plugin' +alias ru='rails runner' +alias rs='rails server' +alias rsd='rails server --debugger' + +# Rake aliases +alias rdm='rake db:migrate' +alias rdr='rake db:rollback' +alias rdc='rake db:create' +alias rds='rake db:seed' +alias rdd='rake db:drop' +alias rdtc='rake db:test:clone' +alias rdtp='rake db:test:prepare' + +alias rlc='rake log:clear' +alias rn='rake notes' +alias rr='rake routes' + +# legacy stuff alias ss='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 rdbm='rake db:migrate' -alias rdbtp='rake db:test:prepare' -alias migrate='rake db:migrate && rake db:test:prepare' alias sc='ruby script/console' alias sd='ruby script/server --debugger' -alias devlog='tail -f log/development.log' -alias testlog='tail -f log/test.log' -alias prodlog='tail -f log/production.log' -alias -g RET='RAILS_ENV=test' -alias -g REP='RAILS_ENV=production' -alias -g RED='RAILS_ENV=development' function remote_console() { /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" diff --git a/plugins/rails3/_rails3 b/plugins/rails3/_rails3 deleted file mode 100644 index 97915e68b..000000000 --- a/plugins/rails3/_rails3 +++ /dev/null @@ -1,56 +0,0 @@ -#compdef rails -#autoload - -# rails 3 zsh completion, based on homebrew completion -# Extracted from https://github.com/robbyrussell/oh-my-zsh/blob/30620d463850c17f86e7a56fbf6a8b5e793a4e07/plugins/rails3/_rails3 -# Published by Christopher Chow - -local -a _1st_arguments -_1st_arguments=( - 'generate:Generate new code (short-cut alias: "g")' - 'console:Start the Rails console (short-cut alias: "c")' - 'server:Start the Rails server (short-cut alias: "s")' - 'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")' - 'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"' - 'application:Generate the Rails application code' - 'destroy:Undo code generated with "generate"' - 'benchmarker:See how fast a piece of code runs' - 'profiler:Get profile information from a piece of code' - 'plugin:Install a plugin' -) - -_rails_generate_arguments() { - generate_arguments=( - controller - generator - helper - integration_test - mailer - migration - model - observer - performance_test - plugin - resource - scaffold - scaffold_controller - session_migration - stylesheets - ) -} - -_arguments \ - '(--version)--version[show version]' \ - '(--help)--help[show help]' \ - '*:: :->subcmds' && return 0 - -if (( CURRENT == 1 )); then - _describe -t commands "rails subcommand" _1st_arguments - return -fi - -case "$words[1]" in - generate) - _rails_generate_arguments - _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;; -esac diff --git a/plugins/rails3/rails3.plugin.zsh b/plugins/rails3/rails3.plugin.zsh deleted file mode 100644 index b53d18d08..000000000 --- a/plugins/rails3/rails3.plugin.zsh +++ /dev/null @@ -1,32 +0,0 @@ -# Rails 3 aliases, backwards-compatible with Rails 2. - -function _rails_command () { - if [ -e "script/server" ]; then - ruby script/$@ - else - if [ -e "bin/rails" ]; then - bin/rails $@ - else - rails $@ - fi - fi -} - -alias rc='_rails_command console' -alias rd='_rails_command destroy' -alias rdb='_rails_command dbconsole' -alias rdbm='rake db:migrate db:test:clone' -alias rg='_rails_command generate' -alias rgm='_rails_command generate migration' -alias rp='_rails_command plugin' -alias ru='_rails_command runner' -alias rs='_rails_command server' -alias rsd='_rails_command server --debugger' -alias devlog='tail -f log/development.log' -alias testlog='tail -f log/test.log' -alias prodlog='tail -f log/production.log' -alias rdm='rake db:migrate' -alias rdr='rake db:rollback' -alias -g RET='RAILS_ENV=test' -alias -g REP='RAILS_ENV=production' -alias -g RED='RAILS_ENV=development' diff --git a/plugins/rails4/rails4.plugin.zsh b/plugins/rails4/rails4.plugin.zsh deleted file mode 100644 index cb6cf816d..000000000 --- a/plugins/rails4/rails4.plugin.zsh +++ /dev/null @@ -1,32 +0,0 @@ -# Rails 4 aliases - -function _rails_command () { - if [ -e "script/server" ]; then - ruby script/$@ - elif [ -e "script/rails" ]; then - ruby script/rails $@ - else - ruby bin/rails $@ - fi -} - -alias rc='_rails_command console' -alias rd='_rails_command destroy' -alias rdb='_rails_command dbconsole' -alias rdbm='rake db:migrate db:test:clone' -alias rg='_rails_command generate' -alias rgm='_rails_command generate migration' -alias rp='_rails_command plugin' -alias ru='_rails_command runner' -alias rs='_rails_command server' -alias rsd='_rails_command server --debugger' -alias devlog='tail -f log/development.log' -alias testlog='tail -f log/test.log' -alias prodlog='tail -f log/production.log' -alias rdm='rake db:migrate' -alias rdc='rake db:create' -alias rdr='rake db:rollback' -alias rds='rake db:seed' -alias rlc='rake log:clear' -alias rn='rake notes' -alias rr='rake routes' -- cgit v1.2.3-70-g09d2 From 1493d88e3f92c7034da5c1b1638ba19544aa3ccb Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sun, 1 Dec 2013 15:31:48 +0100 Subject: Added migration notification for rails plugin --- plugins/rails3/rails3.plugin.zsh | 4 ++++ plugins/rails4/rails4.plugin.zsh | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 plugins/rails3/rails3.plugin.zsh create mode 100644 plugins/rails4/rails4.plugin.zsh diff --git a/plugins/rails3/rails3.plugin.zsh b/plugins/rails3/rails3.plugin.zsh new file mode 100644 index 000000000..261b92108 --- /dev/null +++ b/plugins/rails3/rails3.plugin.zsh @@ -0,0 +1,4 @@ +echo "It looks like you have been using the 'rails3' plugin," +echo "which has been deprecated in favor of a newly consolidated 'rails' plugin." +echo "You will want to modify your ~/.zshrc configuration to begin using it." +echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240" diff --git a/plugins/rails4/rails4.plugin.zsh b/plugins/rails4/rails4.plugin.zsh new file mode 100644 index 000000000..5452c242c --- /dev/null +++ b/plugins/rails4/rails4.plugin.zsh @@ -0,0 +1,4 @@ +echo "It looks like you have been using the 'rails4' plugin," +echo "which has been deprecated in favor of a newly consolidated 'rails' plugin." +echo "You will want to modify your ~/.zshrc configuration to begin using it." +echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240" -- cgit v1.2.3-70-g09d2