Best Command Prompt

Discussion in 'Ruby' started by gewton, Oct 20, 2008.

  1. gewton

    gewton Guest

    There's a good command interpreter for ruby instead of irb? Like
    ipython for python?
     
    gewton, Oct 20, 2008
    #1
    1. Advertising

  2. gewton

    Trans Guest

    On Oct 20, 9:05=A0am, gewton <> wrote:
    > There's a good command interpreter for ruby instead of irb? Like
    > ipython for python?


    How is ipython better than irb?

    I've been using wirble which improves irb a bit (although I hate that
    it doesn't allow duplicate entries in the history --anyone know how to
    fix?).

    T.
     
    Trans, Oct 20, 2008
    #2
    1. Advertising

  3. gewton

    Jens Wille Guest

    hi trans!

    Trans [2008-10-20 15:23]:
    > I've been using wirble which improves irb a bit (although I hate that
    > it doesn't allow duplicate entries in the history --anyone know how to
    > fix?).

    i always hated that it would store history entries in oldest-first
    order. so i just copied the code for save_history from wirble.rb
    into my .irbrc and adjusted it accordingly:

    require 'wirble'

    # save history newest-first, instead of default oldest-first
    class Wirble::History
    def save_history
    return unless Object.const_defined? :IRB

    path, max_size, perms = %w{path size perms}.map { |v| cfg(v) }

    # read lines from history, and truncate the list (if necessary)
    #lines = Readline::HISTORY.to_a.uniq
    lines = Readline::HISTORY.to_a.reverse.uniq.reverse
    lines = lines[-max_size..-1] if lines.size > max_size

    # write the history file
    real_path = File.expand_path(path)
    File.open(real_path, perms) { |fh| fh.puts lines }
    say 'Saved %d lines to history file %s.' % [lines.size, path]
    end
    end

    you could simply change the line that fills the 'lines' array to
    something like this:

    lines = Readline::HISTORY.to_a

    cheers
    jens
     
    Jens Wille, Oct 20, 2008
    #3
  4. 2008/10/20 gewton <>:
    > There's a good command interpreter for ruby instead of irb? Like
    > ipython for python?


    What functionality are you missing in IRB?

    Kind regards

    robert


    --
    remember.guy do |as, often| as.you_can - without end
     
    Robert Klemme, Oct 20, 2008
    #4
  5. gewton

    Trans Guest

    On Oct 20, 9:33=A0am, Jens Wille <> wrote:
    > hi trans!
    >
    > Trans [2008-10-20 15:23]:> I've been using wirble which improves irb a bi=

    t (although I hate that
    > > it doesn't allow duplicate entries in the history --anyone know how to
    > > fix?).

    >
    > i always hated that it would store history entries in oldest-first
    > order. so i just copied the code for save_history from wirble.rb
    > into my .irbrc and adjusted it accordingly:
    >
    > =A0 require 'wirble'
    >
    > =A0 # save history newest-first, instead of default oldest-first
    > =A0 class Wirble::History
    > =A0 =A0 def save_history
    > =A0 =A0 =A0 return unless Object.const_defined? :IRB
    >
    > =A0 =A0 =A0 path, max_size, perms =3D %w{path size perms}.map { |v| cfg(v=

    ) }
    >
    > =A0 =A0 =A0 # read lines from history, and truncate the list (if necessar=

    y)
    > =A0 =A0 =A0 #lines =3D Readline::HISTORY.to_a.uniq
    > =A0 =A0 =A0 lines =3D Readline::HISTORY.to_a.reverse.uniq.reverse
    > =A0 =A0 =A0 lines =3D lines[-max_size..-1] if lines.size > max_size
    >
    > =A0 =A0 =A0 # write the history file
    > =A0 =A0 =A0 real_path =3D File.expand_path(path)
    > =A0 =A0 =A0 File.open(real_path, perms) { |fh| fh.puts lines }
    > =A0 =A0 =A0 say 'Saved %d lines to history file %s.' % [lines.size, path]
    > =A0 =A0 end
    > =A0 end
    >
    > you could simply change the line that fills the 'lines' array to
    > something like this:
    >
    > =A0 =A0 =A0 lines =3D Readline::HISTORY.to_a
    >


    awesome. thanks jens.

    maybe i'll do a little work on wirble to make it more flexible for
    variant preferences like ours and post a patch.

    t.
     
    Trans, Oct 20, 2008
    #5
  6. gewton

    Jens Wille Guest

    Trans [2008-10-20 18:31]:
    > maybe i'll do a little work on wirble to make it more flexible
    > for variant preferences like ours and post a patch.

    that would be great! let me know if i can lend a hand.

    cheers
    jens
     
    Jens Wille, Oct 20, 2008
    #6
  7. Robert Klemme wrote:
    > 2008/10/20 gewton <>:
    >> There's a good command interpreter for ruby instead of irb? Like
    >> ipython for python?

    >
    > What functionality are you missing in IRB?
    >
    > Kind regards
    >
    > robert

    I believe what he's looking for is a *nix command shell (like sh) that
    implements ruby scripting language features.
    --
    Posted via http://www.ruby-forum.com/.
     
    David Warburton, Oct 20, 2008
    #7
  8. On Mon, Oct 20, 2008 at 11:08 AM, David Warburton <> wrote:

    > I believe what he's looking for is a *nix command shell (like sh) that
    > implements ruby scripting language features.


    If that's the case: <http://rush.heroku.com/>

    FWIW,
    --
    Hassan Schroeder ------------------------
     
    Hassan Schroeder, Oct 20, 2008
    #8
    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. Donald Duck

    Best command for running shell command

    Donald Duck, Jul 11, 2006, in forum: Python
    Replies:
    3
    Views:
    410
    iapain
    Jul 11, 2006
  2. chrisdude911
    Replies:
    10
    Views:
    135,429
    srk289
    Mar 10, 2009
  3. gaurav kashyap
    Replies:
    2
    Views:
    622
    gaurav kashyap
    Oct 30, 2008
  4. gaurav kashyap
    Replies:
    3
    Views:
    688
    gaurav kashyap
    Oct 31, 2008
  5. Mel
    Replies:
    10
    Views:
    3,128
    Sailaja Appi
    Feb 13, 2009
Loading...

Share This Page