{"id":13463125,"url":"https://github.com/janlelis/irbtools","last_synced_at":"2025-07-05T16:08:14.670Z","repository":{"id":1102789,"uuid":"966818","full_name":"janlelis/irbtools","owner":"janlelis","description":"Improvements for Ruby's IRB console 💎︎","archived":false,"fork":false,"pushed_at":"2024-10-01T07:35:23.000Z","size":1396,"stargazers_count":921,"open_issues_count":1,"forks_count":27,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-10-29T13:50:23.370Z","etag":null,"topics":["developer-tools","irb","ruby","ruby-console","terminal"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janlelis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-MORE.md","contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2010-10-06T15:48:35.000Z","updated_at":"2024-10-28T08:03:04.000Z","dependencies_parsed_at":"2024-04-24T14:10:29.911Z","dependency_job_id":"b6b83bf6-7d4f-49e5-a904-cfc1d71fa762","html_url":"https://github.com/janlelis/irbtools","commit_stats":{"total_commits":355,"total_committers":7,"mean_commits":"50.714285714285715","dds":"0.20281690140845066","last_synced_commit":"2915cb4663f2776e47f049209fea617daacf7b07"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Firbtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Firbtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Firbtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Firbtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janlelis","download_url":"https://codeload.github.com/janlelis/irbtools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245413867,"owners_count":20611353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","irb","ruby","ruby-console","terminal"],"created_at":"2024-07-31T13:00:46.476Z","updated_at":"2025-03-25T06:31:32.035Z","avatar_url":"https://github.com/janlelis.png","language":"Ruby","readme":"# Irbtools [![[version]](https://badge.fury.io/rb/irbtools.svg)](https://badge.fury.io/rb/irbtools) [![[ci]](https://github.com/janlelis/irbtools/workflows/Test/badge.svg)](https://github.com/janlelis/irbtools/actions?query=workflow%3ATest)\n\n## Irbtools 4 for Current IRB\n\nThe current version of Irbtools requires [IRB 1.13+](https://github.com/ruby/irb) ([which Ruby version bundles which IRB?](https://stdgems.org/irb/)). Please use Irbtools 3 for earlier versions of IRB.\n\n## Description\n\nImproves Ruby's IRB with:\n\n-   a default configuration\n-   improved syntax highlighting of result objects\n-   helpful commands for debugging and introspection\n\n## Examples\n\n### Call system commands with `$`\n\n```ruby\n\u003e\u003e $ git status # displays current git status\n```\n\n### Show lookup chain and method list grouped by visibility\n\n```ruby\n\u003e\u003e shadow [1,2,3].reverse\n=\u003e # ObjectShadow of Object #85280\n\n## Lookup Chain\n\n    [#\u003cClass:#\u003cArray:0x00007fccd9cfac30\u003e\u003e, Array, Enumerable, Object, \"…\"]\n\n## 141 Public Methods (Non-Class/Object)\n\n    [:\u0026, :*, :+, :-, :\u003c\u003c, :\u003c=\u003e, :==, :[], :[]=, :all?, :any?, :append, :assoc, :at, :bsearch, :bsearch_index, :chain,\n    :chunk, :chunk_while, :clear, :collect, :collect!, :collect_concat, :combination, :compact, :compact!, :concat,\n    :count, :cycle, :deconstruct, :delete, :delete_at, :delete_if, :detect, :difference, :dig, :drop, :drop_while,\n    :each, :each_cons, :each_entry, :each_index, :each_slice, :each_with_index, :each_with_object, :empty?, :entries,\n    :eql?, :fetch, :fill, :filter, :filter!, :filter_map, :find, :find_all, :find_index, :first, :flat_map, :flatten,\n    :flatten!, :grep, :grep_v, :group_by, :hash, :include?, :index, :inject, :insert, :inspect, :intersect?,\n    :intersection, :join, :keep_if, :last, :lazy, :length, :map, :map!, :max, :max_by, :member?, :min, :min_by,\n    :minmax, :minmax_by, :none?, :one?, :pack, :partition, :permutation, :pop, :prepend, :product, :push, :rassoc,\n    :reduce, :reject, :reject!, :repeated_combination, :repeated_permutation, :replace, :reverse, :reverse!,\n    :reverse_each, :rindex, :rotate, :rotate!, :sample, :select, :select!, :shelljoin, :shift, :shuffle, :shuffle!,\n    :size, :slice, :slice!, :slice_after, :slice_before, :slice_when, :sort, :sort!, :sort_by, :sort_by!, :sum,\n    :take, :take_while, :tally, :to_a, :to_ary, :to_h, :to_s, :to_set, :transpose, :union, :uniq, :uniq!, :unshift,\n    :values_at, :zip, :|]\n\n## 2 Private Methods (Non-Class/Object)\n\n    [:initialize, :initialize_copy]\n\n## Object Inspect\n\n    [3, 2, 1]\n```\n\n### Show a method list grouped by ancestors\n\n```ruby\n\u003e\u003e look \"str\"\n.\n.\n.\nComparable\n  \u003c  \u003c=  ==  \u003e  \u003e=  between?  clamp\nString\n  %            crypt                  inspect      squeeze!\n  *            dedup                  intern       start_with?\n  +            delete                 length       strip\n  +@           delete!                lines        strip!\n  -@           delete_prefix          ljust        sub\n  \u003c\u003c           delete_prefix!         lstrip       sub!\n  \u003c=\u003e          delete_suffix          lstrip!      succ\n.\n.\n.\n```\n\n### Show source code of a Ruby-based method\n\n```ruby\n\u003e\u003e code SecureRandom.uuid\n#\n#   /home/dan/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/random/formatter.rb:170\n#\n# Generate a random v4 UUID (Universally Unique IDentifier).\n#\n#   require 'random/formatter'\n#\n#   Random.uuid #=\u003e \"2d931510-d99f-494a-8c67-87feb05e1594\"\n#   Random.uuid #=\u003e \"bad85eb9-0713-4da7-8d36-07a8e4b00eab\"\n#   # or\n#   prng = Random.new\n#   prng.uuid #=\u003e \"62936e70-1815-439b-bf89-8492855a7e6b\"\n#\n# The version 4 UUID is purely random (except the version).\n# It doesn't contain meaningful information such as MAC addresses, timestamps, etc.\n#\n# The result contains 122 random bits (15.25 random bytes).\n#\n# See RFC4122[https://datatracker.ietf.org/doc/html/rfc4122] for details of UUID.\n#\ndef uuid\n  ary = random_bytes(16).unpack(\"NnnnnN\")\n  ary[2] = (ary[2] \u0026 0x0fff) | 0x4000\n  ary[3] = (ary[3] \u0026 0x3fff) | 0x8000\n  \"%08x-%04x-%04x-%04x-%04x%08x\" % ary\nend\n```\n\n### Show source code of a natively implemented method\n\n```ruby\n\u003e\u003e code Array#reverse\n//\n//   https://github.com/ruby/ruby/blob/ruby_3_2/array.c#L3282\n//\n// Returns a new \\Array with the elements of +self+ in reverse order:\n//\n//   a = ['foo', 'bar', 'two']\n//   a1 = a.reverse\n//   a1 # =\u003e [\"two\", \"bar\", \"foo\"]\nstatic VALUE\nrb_ary_reverse_m(VALUE ary)\n{\n    long len = RARRAY_LEN(ary);\n    VALUE dup = rb_ary_new2(len);\n\n    if (len \u003e 0) {\n        const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);\n        VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;\n        do *p2-- = *p1++; while (--len \u003e 0);\n    }\n    ARY_SET_LEN(dup, RARRAY_LEN(ary));\n    return dup;\n}\n```\n\n### Find out method signatures (most useful for Ruby-based methods with keyword args)\n\n```ruby\n\u003e\u003e howtocall require\nrequire(path)\n```\n\n```ruby\n\u003e\u003e require \"rubygems/user_interaction\"\n\u003e\u003e ui = Gem::ConsoleUI.new\n\u003e\u003e howtocall ui.choose_from_list\nchoose_from_list(question, list)\n```\n\n## Setup\n\n    $ gem install irbtools\n\nIRB executes code in `~/.irbrc` on start-up. If the file does not exist, yet,\njust create a new one. Add the following content:\n\n    require 'irbtools'\n\nYou also need to add irbtools to your project's `Gemfile`:\n\n    gem 'irbtools', require: 'irbtools/binding'\n\nThen start IRB (with **Irbtools** loaded) from the terminal or directly from\nyour code with:\n\n    binding.irb\n\n_Optional:_ If the **binding_of_caller** gem is available, you can just call the `irb`\nmethod and it will start a session with the current binding:\n\n    irb\n\n## Features\n\n### General IRB Improvements\n\n-   Syntax highlighting ([wirb](https://github.com/janlelis/wirb/) / [fancy_irb](https://github.com/janlelis/fancy_irb))\n-   Loads included libraries efficiently to reduce IRB start-up time\n-   Customizable views for specfic options using [hirb](https://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html). By default, ActiveRecord results get displayed as a table.\n\n### Included Debugging Methods for IRB\n\n#### Highlights\n\n-   Lookup and manipulate instance variables / methods with ease using [object_shadow](https://github.com/janlelis/object_shadow/)\n-   Go even further with [looksee](https://github.com/oggy/looksee), the best lookup path inspection tool out there\n-   Display a method's source code using [code](https://github.com/janlelis/code)\n-   Find methods that turn one value into another value with [methodfinder](https://github.com/citizen428/methodfinder)\n-   [Use VIM from inside IRB](https://github.com/jberkel/interactive_editor)\n\n#### Extra Commands\n\nCommands get treated specially by IRB and do not necessarily follow Ruby syntax.\n\n| Command      | Alias | Description                                      | Example                 |\n| ------------ | ----- | ------------------------------------------------ | ----------------------- |\n| `code `      | -     | Shows syntax-highlighted source code of a method | `code Array#reverse`    |\n| `howtocall ` | -     | Shows the method signature                       | `howtocall String#gsub` |\n| `look `      | -     | Shows looksee method list                        | `look [1,2,3]`          |\n| `shadow `    | `+ `  | Shows object shadow method list                  | `shadow [1,2,3]`        |\n| `sys `       | `$ `  | Calls system shell                               | `$ top`                 |\n\nTwo default commands have an additional alias:\n\n| Command    | Alias | Description             | Example          |\n| ---------- | ----- | ----------------------- | ---------------- |\n| `show_doc` | `ri ` | Shows documentation     | `ri String#gsub` |\n| `chws`     | `co ` | \"change into an object\" | `co [1,2,3]`     |\n\n##### IRB's ls?\n\nPlease note that IRB's own **ls** command is aliased to `ils`, since `ls` already refers to a method listing all files in the current directory. If you haven't tried looksee (`look`) or object shadows (`shadow`) - give it a try ;)\n\n#### Ruby Introspection\n\n| Method / Constant            | Arguments                     | Description                                                                             | Provided By                                                                                    |\n| ---------------------------- | ----------------------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| `Object#lp` or `Object#look` |                               | Supercharged method introspection in IRB                                                | [looksee](https://github.com/oggy/looksee)                                                     |\n| `Object#shadow`              |                               | Manipulate instance variables and learn about callable methods                          | [object_shadow](https://github.com/janlelis/object_shadow/)                                    |\n| `code`                       | object = self, method_name    | Display the method source with syntax highlighting. Will also try to look up C methods. | [code](https://github.com/janlelis/code)                                                       |\n| `howtocall`                  | object = self, method_or_proc | Display parameter names and types you will need to call a method                        | [debugging/howtocall](https://github.com/janlelis/debugging#howtocallobj--self-method_or_proc) |\n| `mf`                         | object1, object2              | Find methods which turn one value into another value                                    | [methodfinder](https://github.com/citizen428/methodfinder)                                     |\n\n#### Platform Info\n\n| Method / Constant | Arguments | Description                        | Provided By                                              |\n| ----------------- | --------- | ---------------------------------- | -------------------------------------------------------- |\n| `OS`              |           | Query operating system information | [os](https://github.com/rdp/os)                          |\n| `RubyVersion`     |           | Show the Ruby version              | [ruby_version](https://github.com/janlelis/ruby_version) |\n| `RubyEngine`      |           | Show the Ruby engine               | [ruby_engine](https://github.com/janlelis/ruby_engine)   |\n\n#### General Utils\n\n| Method / Constant                                        | Arguments                    | Description                                                             | Provided By                                                         |\n| -------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------- |\n| `beep`                                                   |                              | Ring terminal bell                                                      | [debugging/beep](https://github.com/janlelis/debugging#beep)        |\n| `clear`                                                  |                              | Clear the terminal                                                      | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `copy`                                                   | string                       | Copy something to the clipboard                                         | [clipboard](https://github.com/janlelis/clipboard)                  |\n| `copy_output`                                            |                              | Copy session output history to the clipboard                            | [clipboard](https://github.com/janlelis/clipboard), irbtools        |\n| `colorize`                                               | string                       | Syntax-highlight a string of Ruby code                                  | [coderay](https://github.com/rubychan/coderay), irbtools            |\n| `ed` / `emacs` / `mate` / `mvim` / `nano` / `vi` / `vim` | filename = nil               | Start an editor in the session context                                  | [interactive_editor](https://github.com/jberkel/interactive_editor) |\n| `ld`                                                     | file                         | Shortcut for `load lib.to_s + '.rb'`                                    | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `pa`                                                     | string, color                | Print a string in the specified color                                   | [paint](https://github.com/janlelis/paint#utilities)                |\n| `page`                                                   | what, options = {}           | Use pager to improve viewing longer content                             | [hirb](https://github.com/cldwalker/hirb#pager), irbtools           |\n| `paste`                                                  |                              | Paste clipboard content                                                 | [clipboard](https://github.com/janlelis/clipboard)                  |\n| `q`                                                      | \\*args                       | Like `Kernel#p`, but prints results on one line, with different colors  | [debugging/q](https://github.com/janlelis/debugging#qargs)          |\n| `re`                                                     | string, regexg, groups = nil | Regex debugging helper                                                  | [debugging/re](https://github.com/janlelis/debugging#qargs)         |\n| `reset!`                                                 |                              | Restart the current IRB session                                         | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `rq`                                                     | lib                          | Shortcut for `require lib.to_s`. Use it like this: `rq:prime`           | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `rr`                                                     | lib                          | Shortcut for `require_relative lib.to_s`                                | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `rrq` / `rerequire`                                      | lib                          | Hack to remove a library from `$LOADED_FEATURES` and `require` it again | [every_day_irb](https://github.com/janlelis/every_day_irb)          |\n| `wp`                                                     | inspect_string               | Syntax-highlight a Ruby return value                                    | [wirb](https://github.com/janlelis/wirb#kernelwp)                   |\n\n#### Files and Navigation\n\n| Method / Constant | Arguments           | Description                                                                                                                   | Provided By                                                                   |\n| ----------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |\n| `cat`             | path                | Read file contents                                                                                                            | [every_day_irb](https://github.com/janlelis/every_day_irb)                    |\n| `cd`              | path = nil          | Change the directory. Can also be used in these forms: `~cd` (change to home directory), `-cd` (change to previous directory) | [cd](https://github.com/janlelis/cd)                                          |\n| `chmod`           | mode, path          | Set file mode for file                                                                                                        | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `chmod_R`         | mode, path          | Set file mode for directory                                                                                                   | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `chown`           | user, group, path   | Set file owner for file                                                                                                       | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `chown_R`         | user, group, path   | Set file owner for directory                                                                                                  | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `cp`              | source, destination | Copy file                                                                                                                     | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `cp_r`            | source, destination | Copy directory                                                                                                                | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `ls`              | path = \".\"          | List directory content                                                                                                        | [cd](https://github.com/janlelis/cd)                                          |\n| `ln`              | target, link        | Create symlink (`ln`)                                                                                                         | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `ln_s`            | target, link        | Create symlink (`ln -s`)                                                                                                      | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `ln_sf`           | target, link        | Create symlink (`ln -sf`)                                                                                                     | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `mkdir`           | path                | Create a new directory                                                                                                        | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `mkdir_p`         | path                | Create a new directory (with `-p` option)                                                                                     | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `cp`              | source, destination | Move file or directory                                                                                                        | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `pwd`             |                     | Return current directory                                                                                                      | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `ray`             | path                | Syntax highlight a Ruby file                                                                                                  | [coderay](https://github.com/rubychan/coderay), irbtools                      |\n| `rm`              | path                | Delete a file (`rm`)                                                                                                          | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `rm_r`            | path                | Delete a file or directory (`rm -r`)                                                                                          | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `rm_rf`           | path                | Delete a file or directory, with force (`rm -rf`)                                                                             | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n| `rmdir`           | path                | Delete an empty directory                                                                                                     | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html) |\n\n### Advanced Tweaking\n\nSee [CONFIGURE.md](https://github.com/janlelis/irbtools/blob/master/CONFIGURE.md).\n\n### Troubleshooting: ANSI colors on Windows\n\nWindows: ANSI support can be enabled via\n[ansicon](https://github.com/adoxa/ansicon) or\n[ConEmu](https://conemu.github.io/) or\n[WSL](https://docs.microsoft.com/en-us/windows/wsl/about).\n\n### Troubleshooting: Clipboard not working on Linux\n\nClipboard support requires **xsel** or **xclip**. On ubuntu, do:\n\n    sudo apt-get install xsel\n\n### Hint: Debundle\n\nIf you do not want to add **Irbtools** to your project's `Gemfile`, you will need a\n[debundle hack](https://github.com/janlelis/debundle.rb). Put it at the\nbeginning of your `~/.irbrc` file and you are fine.\n\n### Hint: No ANSI / IRB extension\n\nYou can use **Irbtools** without colors/IRB extensions. To do so, put this into `~/.irbrc`:\n\n```ruby\nrequire 'irbtools/non_fancy'\nIrbtools.start\n```\n\n## J-\\_-L\n\nCopyright (c) 2010-2024 Jan Lelis \u003chttps://janlelis.com\u003e released under the MIT\nlicense.\n","funding_links":[],"categories":["Ruby","Developer Tools","IRB"],"sub_categories":["irb Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlelis%2Firbtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanlelis%2Firbtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlelis%2Firbtools/lists"}