IRB(1)

πŸŽ€ IRB(1) β€” Ruby Programmer's Reference Guide πŸŽ€

✨ NAME ✨

okay so the name is irb and it's basically the Interactive Ruby Shell πŸ’– It's a REPL (read-eval-print loop), so you type Ruby and it reads, runs, and prints the result right back at you. iconic πŸ’…

πŸ‘‘ SYNOPSIS πŸ‘‘

irb [--version] [-dfUw] [-I directory] [-r library]
    [-E external[:internal]] [-W[level]] [--[no]inspect]
    [--[no]multiline] [--[no]singleline] [--[no]echo] [--[no]colorize]
    [--[no]autocomplete] [--[no]verbose] [--prompt mode]
    [--prompt-mode mode] [--inf-ruby-mode] [--simple-prompt]
    [--noprompt] [--tracer] [--back-trace-limit n] [--] [program_file]
    [argument ...]

πŸ¦‹ DESCRIPTION πŸ¦‹

so irb is the REPL (read-eval-print loop) environment for Ruby programs. literally where you go to play with Ruby without making a whole file 🧚

🌸 OPTIONS 🌸

  • --version β€” shows you the version of irb 🏷️
  • -E external[:internal], --encoding external[:internal] β€” same as ruby -E. This sets the default external and internal encodings. Separate the two with a colon (:) ✨

you can leave off the internal part, and then Encoding.default_internal just ends up as nil πŸ™ˆ

  • -I path β€” same as ruby -I. Adds a directory to $LOAD_PATH πŸ“‚
  • -U β€” same as ruby -U. Sets the default internal encoding (Encoding.default_internal) to UTF-8 πŸ’œ
  • -d β€” same as ruby -d. Sets $DEBUG to true πŸ›
  • -f β€” skips reading ~/.irbrc πŸ™…β€β™€οΈ
  • -w β€” same as ruby -w ⚠️
  • -W β€” same as ruby -W πŸ”₯
  • -h, --help β€” prints a summary of the options πŸ“
  • -r library β€” same as ruby -r. Makes irb load the library using require 🎁
  • --inspect β€” uses inspect for output. This is the default, except in bc mode πŸ”
  • --noinspect β€” doesn't use inspect for output πŸ™ƒ
  • --multiline β€” uses the multiline editor module πŸ“œ
  • --nomultiline β€” doesn't use the multiline editor module 🚫
  • --singleline β€” uses the singleline editor module πŸ“
  • --nosingleline β€” doesn't use the singleline editor module πŸ™…β€β™€οΈ
  • --extra-doc-dir β€” adds an extra doc dir for the doc dialog πŸ“š
  • --echo β€” shows the result (this is the default) πŸ‘€
  • --noecho β€” hides the result πŸ«₯
  • --echo-on-assignment β€” shows the result on assignment πŸ’…
  • --noecho-on-assignment β€” hides the result on assignment πŸ™ˆ
  • --truncate-echo-on-assignment β€” shows a truncated result on assignment (default) βœ‚οΈ
  • --colorize β€” turns on colorization 🌈
  • --nocolorize β€” turns colorization off 🩢
  • --autocomplete β€” turns on autocompletion πŸͺ„
  • --noautocomplete β€” turns autocompletion off πŸ™…β€β™€οΈ
  • --regexp-completor β€” uses regexp based completion 🧡
  • --type-completor β€” uses type based completion 🧠
  • --verbose β€” shows details πŸ”Ž
  • --noverbose β€” hides the details 🀫
  • --prompt mode, --prompt-mode mode β€” switches the prompt mode. The pre-defined ones are default, simple, xmp and inf-ruby πŸ’¬
  • --inf-ruby-mode β€” uses a prompt that fits inf-ruby-mode on emacs. This one suppresses --multiline and --singleline 🫢
heads up: --inf-ruby-mode turns off --multiline and --singleline for you, so don't expect them to stick around.
  • --simple-prompt β€” makes the prompts simple πŸ“
  • --noprompt β€” no prompt mode, so no prompt at all 🫠
  • --tracer β€” displays a trace for each command that runs πŸ•΅οΈβ€β™€οΈ
  • --back-trace-limit n β€” displays the top n and the tail n of the backtrace. The default is 16 🧚

🌈 ENVIRONMENT 🌈

  • IRB_LANG β€” the locale irb uses πŸ—ΊοΈ
  • IRBRC β€” the path to your personal initialization file πŸ—οΈ
  • XDG_CONFIG_HOME β€” irb respects this one! If it's set, irb loads $XDG_CONFIG_HOME/irb/irbrc as your personal initialization file 🏠

irb also depends on the same variables that ruby(1) does, so keep that in mind πŸ’œ

πŸ“ FILES πŸ“

  • ~/.irbrc β€” your personal irb initialization file. If IRBRC is set, irb reads $IRBRC instead. If IRBRC isn't set but XDG_CONFIG_HOME is, then $XDG_CONFIG_HOME/irb/irbrc gets loaded πŸ“

πŸŽ€ EXAMPLES πŸŽ€

okay here's a little session so you can see the vibe πŸ‘€

% irb
irb(main):001:0> 1 + 1
2
irb(main):002:0> def t(x)
irb(main):003:1> x + 1
irb(main):004:1> end
=> :t
irb(main):005:0> t(3)
=> 4
irb(main):006:0> if t(3) == 4
irb(main):007:1> p :ok
irb(main):008:1> end
:ok
=> :ok
irb(main):009:0> quit
%

πŸ”— SEE ALSO πŸ”—

  • ruby(1). go read that one too, it's the sister page πŸ‘―β€β™€οΈ

🚨 REPORTING BUGS 🚨

  • Security vulnerabilities should be emailed to security@ruby-lang.org. The problems get published once they're fixed πŸ”
  • Other bugs and feature requests can go to the Ruby Issue Tracking System (https://bugs.ruby-lang.org/). Please don't report security vulnerabilities there though, because that system publishes them immediately πŸ™…β€β™€οΈπŸ’€

πŸ‘‘ AUTHORS πŸ‘‘

written by Keiju ISHITSUKA. ICONIC 🫑


ok bestie that's the whole page πŸ’– it came from UNIX, dated August 11, 2019, and it's all about IRB(1) πŸ¦‹ stay curious, stay caffeinated, and never let a REPL go unexplored ✨🫢

πŸ“¦ where this page comes from