Add zsh/oh my zsh/w10k
This commit is contained in:
83
zsh/.oh-my-zsh/plugins/rails/README.md
Normal file
83
zsh/.oh-my-zsh/plugins/rails/README.md
Normal file
@ -0,0 +1,83 @@
|
||||
# Rails
|
||||
|
||||
This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
|
||||
|
||||
To use it, add `rails` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... rails)
|
||||
```
|
||||
|
||||
## List of Aliases
|
||||
|
||||
### Rails aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------------|----------------------------------------------------|
|
||||
| `rc` | `rails console` | Interact with your Rails app from the CLI |
|
||||
| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
|
||||
| `rd` | `rails destroy` | Undo a generate operation |
|
||||
| `rdb` | `rails dbconsole` | Interact with your db from the console |
|
||||
| `rgen`| `rails generate` | Generate boilerplate code |
|
||||
| `rgm` | `rails generate migration` | Generate a db migration |
|
||||
| `rp` | `rails plugin` | Run a Rails plugin command |
|
||||
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
|
||||
| `rs` | `rails server` | Launch a web server |
|
||||
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
|
||||
| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
|
||||
|
||||
### Rake aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|---------------------------------|--------------------------------------------------------|
|
||||
| `rdm` | `rake db:migrate` | Run pending db migrations |
|
||||
| `rdms` | `rake db:migrate:status` | Show current db migration status |
|
||||
| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
|
||||
| `rdr` | `rake db:rollback` | Roll back the last migration |
|
||||
| `rdc` | `rake db:create` | Create the database |
|
||||
| `rds` | `rake db:seed` | Seed the database |
|
||||
| `rdd` | `rake db:drop` | Delete the database |
|
||||
| `rdrs` | `rake db:reset` | Delete the database and set it up again |
|
||||
| `rdtc` | `rake db:test:clone` | Clone the database into the test database |
|
||||
| `rdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
|
||||
| `rdsl` | `rake db:schema:load` | Load the database schema |
|
||||
| `rlc` | `rake log:clear` | Clear Rails logs |
|
||||
| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
|
||||
| `rr` | `rake routes` | List all defined routes |
|
||||
| `rrg` | `rake routes \| grep` | List and filter the defined routes |
|
||||
| `rt` | `rake test` | Run Rails tests |
|
||||
| `rmd` | `rake middleware` | Interact with Rails middlewares |
|
||||
| `rsts` | `rake stats` | Print code statistics |
|
||||
|
||||
### Utility aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|-------------------------------|------------------------------------------------|
|
||||
| `devlog` | `tail -f log/development.log` | Show and follow changes to the development log |
|
||||
| `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log |
|
||||
| `testlog` | `tail -f log/test.log` | Show and follow changes to the test log |
|
||||
|
||||
### Environment settings
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|-------------------------|---------------------------------|
|
||||
| `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development |
|
||||
| `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production |
|
||||
| `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test |
|
||||
|
||||
These are global aliases. Use in combination with a command or just run them
|
||||
separately. For example: `REP rake db:migrate` will migrate the production db.
|
||||
|
||||
### Legacy stuff
|
||||
|
||||
| Alias | Command |
|
||||
|---------|------------------------------------|
|
||||
| `sstat` | `thin --stats "/thin/stats" start` |
|
||||
| `sg` | `ruby script/generate` |
|
||||
| `sd` | `ruby script/destroy` |
|
||||
| `sp` | `ruby script/plugin` |
|
||||
| `sr` | `ruby script/runner` |
|
||||
| `ssp` | `ruby script/spec` |
|
||||
| `sc` | `ruby script/console` |
|
||||
| `sd` | `ruby script/server --debugger` |
|
||||
|
66
zsh/.oh-my-zsh/plugins/rails/_rails
Normal file
66
zsh/.oh-my-zsh/plugins/rails/_rails
Normal file
@ -0,0 +1,66 @@
|
||||
#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
|
||||
else
|
||||
_files
|
||||
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
|
86
zsh/.oh-my-zsh/plugins/rails/rails.plugin.zsh
Normal file
86
zsh/.oh-my-zsh/plugins/rails/rails.plugin.zsh
Normal file
@ -0,0 +1,86 @@
|
||||
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 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 rr='rake routes'
|
||||
alias rrg='rake routes | grep'
|
||||
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 )"
|
||||
}
|
Reference in New Issue
Block a user