While poking around in IRB and looking at the autocompletion results, I found some functions that I didn't recognize and decided to take a look at what they do. I found some pretty interesting stuff.
It looks like some of these commands have been added recently to come
up to par with
pry, and others have been kicking around for a while
and just flying under the radar.
You can find them all defined in this file in the IRB source code.
- The terms workspace/binding/context are used interchangeably
- For some reason these methods have an excessive amount of aliases
irb_push_bindingchange the current context (binding) to whatever object you pass as arg. It pushes your binding onto the
irb_push_bindingpop your current workspace off the stack and take you out and bring you to your previous binding environment.
irb_change_bindingchange the current context without pushing the current context onto the stack, and change to the default context when called without an argument.
Examining object internals
ls [obj]lists the contents of an object (methods, inherited methods, instance variables, etc.)
Switching between multiple IRB sessions (sub-IRBs)
irbcreates a sub-IRB.
jobslists existing sub-IRBs
fg <num>lets you change sub-IRB
kill <num>kills the given sub-IRB
Find the source code for a method or constant
show_source <obj/method>Displays the file path a method or object was defined in, and prints its contents
show_doc [method]Either opens the documentation for the constant or method provided as an argument, or opens an RI documentation prompt of no argument is given.
Show the current line
whereamilists the current line of execution of the binding. This is useful if you open IRB from
List internal IRB commands
show_cmdslists most of these commands inside of IRB :)