shutting irb up

Discussion in 'Ruby' started by Ara.T.Howard, Mar 2, 2007.

  1. Ara.T.Howard

    Ara.T.Howard Guest

    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
    --
    be kind whenever possible... it is always possible.
    - the dalai lama
     
    Ara.T.Howard, Mar 2, 2007
    #1
    1. Advertising

  2. That's a service to humanity.

    On 3/2/07, Ara.T.Howard <> wrote:
    >
    > 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
    > --
    > be kind whenever possible... it is always possible.
    > - the dalai lama
    >
    >



    --
    Giles Bowkett
    http://www.gilesgoatboy.org
    http://gilesbowkett.blogspot.com
    http://giles.tumblr.com/
     
    Giles Bowkett, Mar 2, 2007
    #2
    1. Advertising

  3. Garance A Drosehn wrote:
    > On 3/2/07, Ara.T.Howard <> wrote:
    >>
    >>
    >> 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'

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

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
     
    Joel VanderWerf, Mar 11, 2007
    #3
  4. On 3/12/07, Matt Mower <> wrote:
    > On 11/03/07, Joel VanderWerf <> 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( "" )


    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/

    IPMS/USA Region 12 Coordinator
    http://ipmsr12.denhaven2.com/

    Visit the Project Mercury Wiki Site
    http://www.mercuryspacecraft.com/
     
    Rick DeNatale, Mar 12, 2007
    #4
  5. Matt Mower wrote:
    > On 11/03/07, Joel VanderWerf <> 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]



    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.

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
     
    Joel VanderWerf, Mar 12, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qm9zc29tYQ==?=

    Windows 98 SE freezes when shutting down.

    =?Utf-8?B?Qm9zc29tYQ==?=, Jun 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    590
    Eddie
    Jun 27, 2005
  2. Jack
    Replies:
    2
    Views:
    1,605
  3. Sam Stephenson
    Replies:
    1
    Views:
    238
    Andrew Walrond
    Jun 18, 2005
  4. Replies:
    1
    Views:
    169
    Florian GroƟ
    Oct 26, 2005
  5. anne001
    Replies:
    1
    Views:
    288
    anne001
    Jun 27, 2006
Loading...

Share This Page