Linux "irb" Command Line Options and Examples
Interactive Ruby Shell

irb is the REPL(read-eval-print loop) environment for Ruby programs..


Usage:

irb [--version] [-dfm] [-I directory] [-r library] [--[no]inspect] [--[no]readline] [--prompt mode] [--prompt-mode mode]
[--inf-ruby-mode] [--simple-prompt] [--noprompt] [--tracer] [--back-trace-limit n] [--irb_debug n] [--] [program_file]
[argument ...]




Command Line Options:

--version
Prints the version of irb.
irb --version ...
-E
external[:internal]
irb -E ...
--encoding
Same as `ruby -E' . Specifies the default value(s) for external encodings and internal encoding. Values should be sepa‐rated with colon (:).You can omit the one for internal encodings, then the value (Encoding.default_internal) will be nil.
irb --encoding ...
-I
path Same as `ruby -I' . Specifies $LOAD_PATH directory
irb -I ...
-U
Same as `ruby -U' . Sets the default value for internal encodings (Encoding.default_internal) to UTF-8.
irb -U ...
-d
Same as `ruby -d' . Sets $DEBUG to true.
irb -d ...
-f
Suppresses read of ~/.irbrc.
irb -f ...
--help
Prints a summary of the options.
irb --help ...
-r
library Same as `ruby -r'. Causes irb to load the library using require.
irb -r ...
--inspect
Uses `inspect' for output (default except for bc mode)
irb --inspect ...
--noinspect
Doesn't use inspect for output
irb --noinspect ...
--readline
Uses Readline extension module.
irb --readline ...
--noreadline
Doesn't use Readline extension module.
irb --noreadline ...
--prompt-mode
Switch prompt mode. Pre-defined prompt modes are `default', `simple', `xmp' and `inf-ruby'.
irb --prompt-mode ...
--inf-ruby-mode
Uses prompt appropriate for inf-ruby-mode on emacs. Suppresses --readline.
irb --inf-ruby-mode ...
--simple-prompt
Makes prompts simple.
irb --simple-prompt ...
--tracer
Displays trace for each execution of commands.
irb --tracer ...
--back-trace-limit
Displays backtrace top n and tail n. The default value is 16.
irb --back-trace-limit ...
--irb_debug
ENVIRONMENTIRBRCAlso irb depends on same variables as ruby(1).FILES~/.irbrc Personal irb initialization.EXAMPLES% irbirb(main):001:0> 1 + 12irb(main):002:0> def t(x)irb(main):003:1> x+1irb(main):004:1> end=> :tirb(main):005:0> t(3)=> 4irb(main):006:0> if t(3) == 4irb(main):007:1> p :okirb(main):008:1> end:ok=> :okirb(main):009:0> quit%
irb --irb_debug ...