Description

Provides ruby-debug command and command arguments completion with a completion system more powerful than irb’s, compliments of bond.

Install

Install the gem with:

sudo gem install ruby-debug-completion

Setup

To have ruby-debug automatically use this gem:

echo "eval require 'ruby-debug/completion'" >> ~/.rdebugrc

Or to require in a script or application, place after your ‘require ’ruby-debug’‘ line:

require 'ruby-debug/completion'

Or if you like to debug with one-liners:

require 'ruby-debug/completion'; debugger

Or if using rdebug:

rdebug -r ruby-debug/completion FILE

To start manually in environments with bond completion already setup i.e. irb:

require 'ruby-debug/completion'
Debugger::Completion.start

Usage

Let’s autocomplete instance and local variables of the current binding as well as ruby-debug commands:

   186    end
   187
   188    def render
   189      body = []
   190      require 'ruby-debug'; debugger
=> 191      unless @rows.length == 0
   192        setup_field_lengths
   193        body += render_header
   194        body += render_rows
   195        body += render_footer

(rdb:1) [TAB]
@fields            condition          finish             ps                 thread
@filter_classes    continue           frame              putl               tmate
@headers           delete             help               quit               trace
@options           disable            info               reload             undisplay
@rows              display            irb                restart            up
backtrace          down               list               save               var
body               edit               method             set                where
break              enable             next               show               
catch              eval               p                  source             
completion_toggle  exit               pp                 step               

(rdb:1) ca[TAB]
(rdb:1) catch

(rdb:1) @fie[TAB]
(rdb:1) @fields

(rdb:1) bo[TAB]
(rdb:1) body

Autocomplete methods of local and instance variables:

(rdb:1) @filter_classes.[TAB]
Display all 150 possibilities? (y or n)

(rdb:1) body.[TAB]
Display all 168 possibilities? (y or n)

Autocomplete ruby-debug command arguments:

# What info does ruby-debug provide?
(rdb:1) info [TAB]
args                display             global_variables    locals              thread
breakpoints         file                instance_variables  program             threads
catch               files               line                stack               variables

(rdb: 1) info d[TAB]
(rdb: 1) info display

# What settings can I change?
(rdb:1) set [TAB]
annotate             autolist             forcestep            linetrace            width
args                 basename             fullpath             linetrace+           
autoeval             callstyle            history              listsize             
autoirb              debuggertesting      keep-frame-bindings  trace                

(rdb:1) set d[TAB]
(rdb:1) set debuggertesting

Since I have autoeval on, why not autocomplete as if I’m in irb?

# Execute command provided by this gem
(rdb:1) completion_toggle  # also aliased to ct

# irb-like completion has been enabled
(rdb:1) [TAB]
Display all 347 possibilities? (y or n)

(rdb:1) De[TAB]
(rdb:1) Debugger
(rdb:1) Debugger.[TAB]
Display all 137 possibilities? (y or n)

(rdb:1) require 'ab[TAB]
(rdb:1) require 'abbrev.rb'

Huh? Argument autocompletion? See bond for all that you can autocomplete.

Can I go back to basic ruby-debug completion?

# Invoke completion_toggle again
(rdb:1)  completion_toggle

(rdb:1) [TAB]
@fields            condition          finish             ps                 thread
@filter_classes    continue           frame              putl               tmate
@headers           delete             help               quit               trace
@options           disable            info               reload             undisplay
@rows              display            irb                restart            up
backtrace          down               list               save               var
body               edit               method             set                where
break              enable             next               show               
catch              eval               p                  source             
completion_toggle  exit               pp                 step

Please, can I just quit quickly without a prompt?

(rdb:1) q [TAB]
(rdb:1) q unconditionally

Limitations

This gem doesn’t have ruby-debug as a dependency since ruby-debug is split across two gems (ruby-debug and ruby-debug19), dependent on ruby versions. This gem will work with either one.

Bugs/Issues

Please report them on github.