From: "Brian Schröder" Date: 2004-10-06T19:32:41+09:00 Subject: Re: irb request 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 > A partial answer is: $ irb --prompt-mode xmp 1 + 2 ==>3 5-3 ==>2 For more information read man irb As i see it, it is not possible to get the output on the line. Maybe also investigate the emacs xmp package. regards, Brian ---- part of man irb ---- Customizing prompt To costomize the prompt you set a variable IRB.conf[:PROMPT] For example, describe as follows in `.irbrc'. IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode :PROMPT_I => nil, # normal prompt :PROMPT_S => nil, # prompt for continuated strings :PROMPT_C => nil, # prompt for continuated statement :RETURN => " ==>%s\n" # format to return value } Then, invoke irb with the above prompt mode by $ irb1.8 --prompt my-prompt Or add the following in `.irbrc'. IRB.conf[:PROMPT_MODE] = :MY_PROMPT Constants PROMPT_I, PROMPT_S and PROMPT_C specifies the format. In the prompt specification, some special strings are available. %N command name which is running %m to_s of main object (self) %M inspect of main object (self) %l type of string(", ', /, ]), `]' is inner %w[...] %NNi indent level. NN is degits and means as same as printf("%NNd"). It can be ommited %NNn line number. %% % For instance, the default prompt mode is defined as follows: IRB.conf[:PROMPT_MODE][:DEFAULT] = { PROMPT_I => "%N(%m):%03n:%i> ", PROMPT_S => "%N(%m):%03n:%i%l ", PROMPT_C => "%N(%m):%03n:%i* ", RETURN => "%s\n"} RETURN is used to printf. -- Brian Schr�der http://ruby.brian-schroeder.de/