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.

  • IRB workspaces

    • The terms workspace/binding/context are used interchangeably
    • For some reason these methods have an excessive amount of aliases
    • pushb <obj>, pushws, irb_push_workspace, irb_push_binding change the current context (binding) to whatever object you pass as arg. It pushes your binding onto the workspaces stack.
    • popb, popws, irb_pop_workspace, irb_push_binding pop your current workspace off the stack and take you out and bring you to your previous binding environment.
    • cb [obj], cws, chwd, irb_cb, irb_cws, irb_chws, irb_change_binding change 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)

    • Running irb creates a sub-IRB.
    • jobs lists 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
  • Read documentation

    • 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

    • whereami lists the current line of execution of the binding. This is useful if you open IRB from binding.irb or binding.b
  • List internal IRB commands

    • show_cmds lists most of these commands inside of IRB :)