# Shutting irb up

**URL:** <https://www.ruby-forum.com/t/shutting-irb-up/87475>\
**Category:** Ruby\
**Created:** [March 2, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475 "2007-03-02T21:14:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 2, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/1 "2007-03-02T21:14:24Z")

</div>

i looked forever, didn’t find this, and am posting for posterity

harp:~ \> cat .irbrc  
IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE] ][:RETURN]=’’

harp :~ \> irb  
irb(main):001:0\> 42  
irb(main):002:0\> 43  
irb(main):003:0\> puts 42  
42  
irb(main):004:0\> p 42  
42  
irb(main):005:0\> p ‘no echo’  
“no echo”  
irb(main):006:0\> ‘no echo’

-a

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 2, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/2 "2007-03-02T21:17:24Z")

</div>

That’s a service to humanity.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2007, 9:44pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/3 "2007-03-07T21:44:57Z")

</div>

On 3/2/07, Ara.T.Howard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):003:0\> puts 42  
> 42  
> irb(main):004:0\> p 42  
> 42  
> irb(main):005:0\> p ‘no echo’  
> “no echo”  
> irb(main):006:0\> ‘no echo’

Hmm, that’s pretty neat. It seems like it only works in .irbrc. It’d  
be  
nice  
if one could turn that off in the middle of a session in irb. Still,  
it’s  
nice  
to know it can be turned off at all! Thanks.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 11, 2007, 9:25am UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/4 "2007-03-11T09:25:07Z")

</div>

Garance A Drosehn wrote:

> > irb(main):002:0\> 43  
> > Hmm, that’s pretty neat. It seems like it only works in .irbrc. It’d be  
> > nice  
> > if one could turn that off in the middle of a session in irb. Still, it’s  
> > nice  
> > to know it can be turned off at all! Thanks.

You can turn it on and off by destructively modifying the string, this  
way:

irb(main):027:0\> IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE] ][:RETURN]  
=\> “=\> %s\n”  
irb(main):028:0\> IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE]  
][:RETURN].replace(’’)  
irb(main):029:0\> 1+2  
irb(main):030:0\> IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE]  
][:RETURN].replace("=\> %s\n")  
=\> “=\> %s\n”  
irb(main):031:0\> 1+2  
=\> 3

It should be pretty easy to define a function in your .irbrc that wraps  
this up nicely…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/5 "2007-03-12T14:52:41Z")

</div>

On 11/03/07, Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):028:0\> IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE]  
> ][:RETURN].replace(‘’)  
> irb(main):029:0\> 1+2

Is this bound to some specific version of Ruby/IRB because it doesn’t  
seem  
to be working for me either in .irbrc or IRB itself:

> > IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE] ][:RETURN].replace( “” )  
> > =\> “”  
> > 2 + 3  
> > =\> 5

Alia:~/Projects/cominded/chitchat matt$ irb -v  
irb 0.9.5(05/04/13)

Alia:~/Projects/cominded/chitchat matt$ ruby -v  
ruby 1.8.5 (2006-08-25) [i686-darwin8.8.2]

But I really wish it would!

Regards,

Matt

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2007, 3:40pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/6 "2007-03-12T15:40:48Z")

</div>

On 3/12/07, Matt M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE] ][:RETURN].replace( “” )  
> > > I put this in my .irbc

module IRB  
def self.result\_format  
conf[:PROMPT][conf[:PROMPT\_MODE]][:RETURN]  
end

def self.result\_format=(str)  
result\_format.replace(str)  
end

def self.show\_results  
self.result\_format = “=\> %s\n”  
end

def self.hide\_results  
self.result\_format = ‘’  
end  
end

rick@frodo:~$ irb  
irb(main):001:0\> 1+2  
=\> 3  
irb(main):002:0\> IRB.result\_format  
=\> “=\> %s\n”  
irb(main):003:0\> IRB.hide\_results  
irb(main):004:0\> 1+2  
irb(main):005:0\> IRB.show\_results  
=\> “=\> %s\n”  
irb(main):006:0\> 1+2  
=\> 3  
irb(main):007:0\>

I’m not sure that I’m in love with my naming, but it does seem to  
work.

One thing I just discovered. I’ve got a few different versions of irb  
installed.

If I try to run irb1.8.5 it doesn’t seem to find ~/.irbc If I  
symlinked ~/.irb1.8.5rc to ~/.irbrc it seemed to work.

YMMV

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

IPMS/USA Region 12 Coordinator  
[http://ipmsr12.denhaven2.com/](http://ipmsr12.denhaven2.com/)

Visit the Project Mercury Wiki Site  
[http://www.mercuryspacecraft.com/](http://www.mercuryspacecraft.com/)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2007, 5:55pm UTC](https://www.ruby-forum.com/t/shutting-irb-up/87475/7 "2007-03-12T17:55:10Z")

</div>

Matt M. wrote:

> > > IRB.conf[:PROMPT][IRB.conf[:PROMPT\_MODE] ][:RETURN].replace( “” )  
> > > =\> “”
> > 
> > > 2 + 3  
> > > =\> 5
> 
> Alia:~/Projects/cominded/chitchat matt$ irb -v  
> irb 0.9.5(05/04/13)
> 
> Alia:~/Projects/cominded/chitchat matt$ ruby -v  
> ruby 1.8.5 (2006-08-25) [i686-darwin8.8.2]

Works for me with the same irb version as yours, and ruby-1.8.4 and also  
ruby-1.8.6-preview3, on ubuntu. Haven’t tried 1.8.5 though.
