irbtools 0,0,0,0,0 editorconfig rspec travis-ci ruby Rubygems

Improvements for Ruby's IRB console

3 years after MIT

Irbtools version

 _ _|        |      |                  |
   |    __|  __ \   __|   _ \    _ \   |   __|
   |   |     |   |  |    (   |  (   |  | \__ \
 ___| _|    _.__/  \__| \___/  \___/  _| ____/

Improvements for Ruby's IRB console, like colored output and a lot of debugging and introspection methods. Unlike with PRY, you are still in your normal IRB. It is designed to work out-of-the-box, so there is no reason to not use it!

Setup

$ gem install irbtools

IRB executes code in ~/.irbrc on start-up. If the file does not exist, yet, just create a new one. Add the following content:

require 'irbtools'

You also need to add irbtools to your project's Gemfile:

gem 'irbtools', require: 'irbtools/binding'

Then start IRB (with Irbtools loaded) from the console or directly from your code with:

binding.irb

If the binding_of_caller gem is available (e.g. see below), you can omit the binding:

irb

More Improvements

Some suggested gems will not be installed to ensure wider general support. For the full feature set, you can add irbtools-more and change your .irbrc to:

require 'irbtools/more'

and edit your Gemfile to

gem 'irbtools-more', require: 'irbtools/binding'

Included Gems and Libraries

IRB Improvements

  • Colored output: wirb fanycy_irb
  • Custom views for specific objects: hirb
  • (irbtools-more) Correction suggestions for misspelled method/constant names: did_you_mean
  • (irbtools-more) Better tab-completion: bond

Utils

Introspection

Irbtools Methods

Besides improving IRB itself, you will get the following methods:

Method Arguments Description
beep Ring terminal bell.
cat path Read file contents.
cd path = nil Changes the directory. Can also be used in these forms: ~cd (change to home directory), -cd (change to previous directory).
clear Clear the terminal.
code object = self, method_name Display the method source with syntax highlighting. Will also look up C methods if the core_docs gem is available.
colorize string Syntax highlight a Ruby string.
copy string Copy something to the clipboard.
copy_input Copy session history to the clipboard.
copy_output Copy session output history to the clipboard.
ed / emacs / mate / mvim / nano / vi / vim filename = nil Start an editor in the session context.
engine Show the Ruby engine.
howtocall object = self, method_or_proc Displays parameter names and types for a proc or method.
info List general information about the Ruby environment.
ld file Shortcut for load lib.to_s + '.rb'.
ls path = "." List directory content.
mf object1, object2 Find methods that turn one value into another value.
mof object, depth = 0, grep = // Print a method list, ordered by modules.
os Query operating system information.
pa string, color Print a string in the specified color.
page what, options = {} Page long content.
paste Paste clipboard content.
q *args Like Kernel#p, but prints results on one line, with different colors.
ray path Syntax highlight a Ruby file.
re string, regexg, groups = nil Assists you when matching regexes againts strings.
reset! Restart the current IRB session.
rq lib Shortcut for require lib.to_s. Use it like this: rq:prime.
rr lib Shortcut for require_relative lib.to_s.
rrq / rerequire lib Hack to remove a library from $LOADED_FEATURES and require it again.
session_history number_of_lines = nil Return a string of all commands issued in the current session.
version Show the Ruby version.
wp inspect_string Syntax-highlight a Ruby object.
Object#instance Proxy object to read and manipulate instance variables / run eval.
Object#lp (irbtools-more) Supercharged method introspection in IRB.
Object#mlp / Object#method_lookup_path Traverse an object's method lookup path to find all places where a method may be defined.
Object#ri *args Show ri documentation for this object or method.

Advanced tweaking

See CONFIGURE.md.

Troubleshooting: ANSI colors on Windows

Windows: ANSI support can be enabled via ansicon or ConEmu.

Troubleshooting: Clipboard not working on Linux

Clipboard support requires xclip or xsel. On ubuntu, do: sudo apt-get install xclip

Troubleshooting: Unicode causes wrong display widths

If you use double-width unicode characters, you will need to paste the following snippet to your ~/.irbrc file.

Irbtools.replace_library_callback :fancy_irb do
  FancyIrb.start east_asian_width: true
end

This setting is deactivated by default, because of performance issues.

Hint: Debundle

If you do not want to add Irbtools to your project's Gemfile, you will need a debundle hack. Put it at the beginning of your ~/.irbrc file and you are fine (until it breaks).

Hint: No ANSI / IRB extension

You can use Irbtools without colors/irb extensions. To do so, put this into ~/.irbrc:

require 'irbtools/non_fancy'
Irbtools.start

Hint: Web Console

Irbtools works well together with the amazing web-console!

J-_-L

Copyright (c) 2010-2015 Jan Lelis http://janlelis.com released under the MIT license.

Related Repositories

awesome-ruby

awesome-ruby

:gem: A collection of awesome Ruby libraries, tools, frameworks and software ...

ruby-dev-bookmarks

ruby-dev-bookmarks

A list of ruby development resources I've collected. Pull requests are welcome. ...

ripl

ripl

ruby interactive print loop - A light, modular alternative to irb ...

wirb

wirb

Don't use an IRB without WIRB! ...

debundle.rb

debundle.rb

Allows you to use gems not in your Gemfile. ...


Top Contributors

janlelis amatsuda halan aripollak b264

Releases

-   v2.0.1 zip tar
-   m2.2.0 zip tar
-   m2.1.0 zip tar
-   2.0.0 zip tar
-   1.7.1 zip tar
-   1.7.0 zip tar
-   1.6.1 zip tar
-   1.6.0 zip tar
-   1.5.1 zip tar
-   1.5.0 zip tar
-   1.4.0 zip tar
-   1.2.3 zip tar
-   1.2.2 zip tar
-   1.2.1 zip tar
-   1.2.0 zip tar
-   1.1.1 zip tar
-   1.1.0 zip tar
-   1.0.6 zip tar
-   1.0.5 zip tar
-   1.0.4 zip tar
-   1.0.3 zip tar
-   1.0.2 zip tar
-   1.0.1 zip tar
-   1.0.0 zip tar
-   0.8.8 zip tar
-   0.8.7 zip tar
-   0.8.6 zip tar
-   0.8.5 zip tar
-   0.8.4 zip tar
-   0.8.3 zip tar