1

I'm reading an eBook for EXTREME beginners in Ruby. It's walking me through VERY step-by-step, but I want to make sure I'm doing it right before I move on.

My first problem was when I typed irb. Instead of getting irb(main):001:0> like I was supposed to, I just got >>. I finally found how to change my prompt format to inf-ruby.

NOW, I'm worried about missing the other prefixes on each line. There are no resulting =>s or >s. Can someone explain to me (very simply) how to "turn those on" so that I can compare my code exactly to my book?

Thank you so much.

(I'm on Mac OS X 1.7, Ruby 1.8.7, using terminal)

robustus
  • 3,626
  • 1
  • 26
  • 24
regan_leah
  • 284
  • 2
  • 3
  • 14
  • How did you find how to change your prompt format? Have you looked at any irb documentation? – Aaron Kurtzhals Aug 15 '12 at 20:51
  • I found it on stackoverflow by Googling the problem. I learned how to use `--help`, but Googling "=>" doesn't turn up many relevant results, as you can imagine, and I don't even know the terminology to help me look. We're talking EXTREME beginner, even to Terminal. – regan_leah Aug 15 '12 at 20:57
  • I did a search for "irb change prompt". Do these help? http://stackoverflow.com/questions/6039292/how-to-format-irb-command-prompt http://stackoverflow.com/questions/2466680/whats-the-difference-between-the-ruby-irb-prompt-modes – Aaron Kurtzhals Aug 15 '12 at 21:03
  • 1
    What does your `~/.irbrc` look like? – Brian Aug 15 '12 at 21:15
  • Aaron, that second one helped. When I used `irb --prompt xmp -f` like the suggestion said, I did get a resulting `==>`. I'm not sure I understand how it works, but I'm sure I'll get there. This is close enough. – regan_leah Aug 15 '12 at 21:26
  • Make sure the book is *also* for Ruby 1.8, or you'll run into some... interesting differences. That said, the environment from which you run your code is maleable, and if you run your code as a script you won't see *any* irb output. Focus on what's important, IMO. – Dave Newton Aug 16 '12 at 00:36
  • 2
    FYI, it is not at all a problem in any way whatsoever that your prompt looks different than the book's prompt. These are simply for conveying information (that you almost certainly don't need) and aesthetics. If you cannot figure out how to make the prompt look the same, then don't sweat it, you can move on with your book (I'm assuming you still see the result of the evaluated line, that would be important feedback -- e.g `2 + 3` does display `5`) – Joshua Cheek Aug 16 '12 at 03:15
  • Thank you all for your help - I'm in Chapter 3 and rolling! I have run into some instances when it was good to know things such as what-line-I'm-working-on and such, so the details really do help! And, of course, 2 + 3 still equals 5! – regan_leah Aug 16 '12 at 15:53

2 Answers2

1

try

irb --prompt default

or

irb --prompt inf-ruby --readline

or this after irb starts

conf.prompt_c="%N(%m):%03n:%i* "
conf.prompt_i="%N(%m):%03n:%i> "
conf.prompt_mode=:DEFAULT
conf.prompt_n="%N(%m):%03n:%i> "
conf.prompt_s="%N(%m):%03n:%i%l "

also check irb --help it has some great help use that :)

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
0

Did you run irb --prompt simple?

This explains:
http://tagaholic.me/2009/05/29/exploring-how-to-configure-irb.html#prompt

Mark Bolusmjak
  • 23,606
  • 10
  • 74
  • 129