irb question

  • Thread starter Darren Nickerson
  • Start date
D

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.
 
Q

Quintus

-----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-----
 
R

Ruby Program

Darren said:
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
 
M

Marvin Gülker

Darren said:
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
 
H

Hassan Schroeder

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 :)

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

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

Jeremy Bopp

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. :)

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
 
D

Darren Nickerson

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
 
D

Darren Nickerson

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

Ed Howland

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top