Irb question

Hi,
Iam starting to learn ruby, today is my first day actually working with
terminal and things are going pretty good. I just have a quick question,
when I go into irb the book I am reading (“Ruby novice to professional”
from apress ) tells me that there should be irb(main):001:0> each line,
but for me all I have is >>
all the ruby commands work fine. I just don’t like not having the line
numbers. This is probably very simple but please help a newbie out.
Thanks for your time.

Darren Nickerson wrote:

Hi,
Iam starting to learn ruby, today is my first day actually working with
terminal and things are going pretty good. I just have a quick question,
when I go into irb the book I am reading (“Ruby novice to professional”
from apress ) tells me that there should be irb(main):001:0> each line,
but for me all I have is >>
all the ruby commands work fine. I just don’t like not having the line
numbers. This is probably very simple but please help a newbie out.
Thanks for your time.

I looked into it and I can only guess since you did not state it. But >>
seems to be the mac irb style, => for linux and irb(main):001:0> style
for windows. So if you want to have the numbers I suggest you invest
into an ide or text editor. There are many choices some of the free
options are netbeans for an ide and notepad++ for text editor. Those
both come with the option to have numbered lines.

If you like it in the irb you will have to run a windows machine it
seems.

Hope this helps

Darren Nickerson wrote:

Hi,
Iam starting to learn ruby, today is my first day actually working with
terminal and things are going pretty good. I just have a quick question,
when I go into irb the book I am reading (“Ruby novice to professional”
from apress ) tells me that there should be irb(main):001:0> each line,
but for me all I have is >>
all the ruby commands work fine. I just don’t like not having the line
numbers. This is probably very simple but please help a newbie out.
Thanks for your time.

Try starting irb like this:

irb --prompt-mode default

Marvin

On 10/09/2010 04:54 PM, Ruby P. wrote:

I looked into it and I can only guess since you did not state it. But >>
seems to be the mac irb style, => for linux and irb(main):001:0> style
for windows. So if you want to have the numbers I suggest you invest
into an ide or text editor. There are many choices some of the free
options are netbeans for an ide and notepad++ for text editor. Those
both come with the option to have numbered lines.

If you like it in the irb you will have to run a windows machine it
seems.

On my Ubuntu system, the prompt has the desired style with line numbers:

$ irb
irb(main):001:0>

This is simply a difference in the default prompt as defined by the
version of irb, the system defaults for irb, and/or the user overrides
for irb. The irb prompt is actually equally configurable on any
platform from what I’ve seen. :slight_smile:

http://ruby-doc.org/docs/ProgrammingRuby/html/irb.html

Search for “Configuring the Prompt”. I’m sure there are other sources
for information as well.

-Jeremy

Thanks guys for the information. I Guess its not a big deal, I was just
confused why my terminal looked different than the one in the book. It
seems like you don’t have to use the terminal all the time. I can’t wait
to know more about ruby for sure

On Sat, Oct 9, 2010 at 2:54 PM, Ruby P. [email protected]
wrote:

I looked into it and I can only guess since you did not state it. But >>
seems to be the mac irb style, => for linux and irb(main):001:0> style
for windows. So if you want to have the numbers I suggest you invest
into an ide or text editor. There are many choices some of the free
options are netbeans for an ide and notepad++ for text editor. Those
both come with the option to have numbered lines.

If you like it in the irb you will have to run a windows machine it seems.

Thanks, that was good for a laugh :slight_smile:

On Mac OS X – ruby 1.8.7 (2009-06-12 patchlevel 174)
[universal-darwin10.0]

ripple:~$ irb --prompt default

ripple:~$ irb --prompt inf-ruby
irb(main):001:0>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 09.10.2010 14:46, schrieb Darren Nickerson:

Hi,
Iam starting to learn ruby, today is my first day actually working with
terminal and things are going pretty good. I just have a quick question,
when I go into irb the book I am reading (“Ruby novice to professional”
from apress ) tells me that there should be irb(main):001:0> each line,
but for me all I have is >>
all the ruby commands work fine. I just don’t like not having the line
numbers. This is probably very simple but please help a newbie out.
Thanks for your time.

Looks like something has set IRB to show the simple prompt instead of
the default one. Do you have a ~/.irbrc file and if so, could you show
the contents?
For the meantime, try starting irb like this:

irb --prompt-mode default

This should show the normal prompt.

Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMsHMWAAoJEGrS0YjAWTKVcPcH/1GAuz08HtcrZuxfEoP1ZK7B
p6iuOhN7RNzD/EGulzljzcvQPKyifpYp/Xf7qFtx7ie1PHbNql0H+tq8LvB4FtB9
ZjVi/TvykfYACOrjdIktw6WIc1Aa0lp9rzquffywbb/aD8P/BDEl+bDOCOjC82oo
d7Qv7LkdpH6Cz40hpZgNE2UWRGDIYajPVQwvv0WOzC5HQo4tSyHv2esr/Kgys6u0
U0NF5NAkSm2+U8XkfkWGU0S1Mcvlm+lbELxJYIKvOqoJctApJT99QplZb1H1AfUG
K1p1XZXj7pzDcSjl7dFBu+Q/I9PGTulnXm5EohKwhXlz7PENndL7lzwjU+7ifoQ=
=4RuX
-----END PGP SIGNATURE-----

Thanks for this.

I wondered about RVM’s prompt. I noticed it auto-indenting when
starting a block/class/def etc,

RVM sets the prompt:
:RVM=>
{:PROMPT_I=>"ruby-1.9.2-p0 > ",
:PROMPT_S=>"ruby-1.9.2-p0%l> ",
:PROMPT_C=>"ruby-1.9.2-p0 > ",
:PROMPT_N=>“ruby-1.9.2-p0 ?> “,
:RETURN=>” => %s \n”,
:AUTO_INDENT=>true}}

So the AUTO_INDENT flag is true. Nice! Also, it shows the current rubie.

Cheers,
Ed

Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland

The command irb --prompt inf-ruby worked to get it looking like the way
I want it to. thanks guys

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs