Joel VanderWerf
10/18/2004 10:32:00 PM
Peña, Botp wrote:
> Hi All:
>
> Forgive me in advance for this stupid request:
>
> How can I make irb work
>
> from this:
> ------------------
> irb(main):015:0> 1
> => 1
> irb(main):016:0> 2+2
> => 4
> irb(main):017:0>
> irb(main):018:0> 5.times{p "hello ruby"}
> "hello ruby"
> "hello ruby"
> "hello ruby"
> "hello ruby"
> "hello ruby"
> => 5
> ------------------
>
>
> to this:
> ------------------
> 1 #=> 1
> 2+2 #=> 4
>
> 5.times{p "hello ruby"} #"hello ruby"
> #"hello ruby"
> #"hello ruby"
> #"hello ruby"
> #"hello ruby"
> #=> 5
> ------------------
>
> iow,
>
> 1. I want to remove the prompt char
> 2. I want output of irb not to be placed right below, but right next at a
> certain column (so that output aligns)
> 3. I want the output prefixed w # char (easy for cut & paste)
>
> thanks in advance
> -botp
Sorry for the late reply--here's something Nobu came up with on
ruby-talk a while ago:
In your .irbrc, put this line:
IRB.conf[:PROMPT][:XMP][:RETURN] = "# => %s\n"
Then run irb using the xmp mode as Brian suggested:
$ irb --prompt-mode xmp
4
# => 4
Not exactly what you asked for, but it's still useful for copy-pasting
from irb into ruby-talk posts!
If you want to comment out stdout lines as well as irb's output lines,
you might try modifying the STDOUT IO object to put a # at the beginning
of each line.
HTH.