# Editing on the command line

**URL:** <https://www.ruby-forum.com/t/editing-on-the-command-line/92067>\
**Category:** Ruby\
**Created:** [April 15, 2007, 5:22pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067 "2007-04-15T17:22:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 15, 2007, 5:22pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067/1 "2007-04-15T17:22:06Z")

</div>

I want to output some text to the the terminal and allow the user to  
edit it. Like the ability you get when using irb and go back in the  
history. Basically a readline but the outputted text would be  
editable instead of a prompt. I cannot find any way to do this using  
standard tools or with any libraries. Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 15, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067/2 "2007-04-15T18:15:29Z")

</div>

On 15.04.2007 17:20, greg wrote:

> I want to output some text to the the terminal and allow the user to  
> edit it. Like the ability you get when using irb and go back in the  
> history. Basically a readline but the outputted text would be  
> editable instead of a prompt. I cannot find any way to do this using  
> standard tools or with any libraries. Any help is greatly appreciated.

If you are on some kind of Unix your favorite shell usually offers this  
service. IIRC Ruby comes with readline built in, so you might be able  
to use it from a Ruby program. Does that help?

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 15, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067/3 "2007-04-15T18:40:02Z")

</div>

I am looking for cross-shell/platform compatibility, but if there is a  
way to delegate this task to the shell I would be interested in  
knowing anyways.  
It seems there are over ten IRC libraries, which one are you referring  
too? I doubt those libraries would be doing anything other than the  
standard Readline.readline though.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 15, 2007, 7:06pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067/4 "2007-04-15T19:06:26Z")

</div>

greg wrote:

> On Apr 15, 11:15 am, Robert K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > On 15.04.2007 17:20, greg wrote:
> > 
> > > I want to output some text to the the terminal and allow the user  
> > > to  
> > > edit it. Like the ability you get when using irb and go back in  
> > > the  
> > > history. Basically a readline but the outputted text would be  
> > > editable instead of a prompt. I cannot find any way to do this  
> > > using standard tools or with any libraries. Any help is greatly  
> > > appreciated.  
> > > If you are on some kind of Unix your favorite shell usually offers  
> > > this service. IIRC Ruby comes with readline built in, so you might  
> > > be able to use it from a Ruby program. Does that help?

> I am looking for cross-shell/platform compatibility, but if there is a  
> way to delegate this task to the shell I would be interested in  
> knowing anyways.  
> It seems there are over ten IRC libraries, which one are you referring  
> too? I doubt those libraries would be doing anything other than the  
> standard Readline.readline though.

Firstly:  
A: It messes with the readability of responses.  
Q: Why is top-quoting bad?

Secondly:  
IIRC == “If I Remember Correctly” != Internet Relay Chat.

Thirdly:  
Readline.readline is what Robert K. meant, if I parse the thread  
correctly.

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Eek! That was supposed to be My Special Law, _MY_ special law, I tell  
you!

T/

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 15, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/editing-on-the-command-line/92067/5 "2007-04-15T20:39:47Z")

</div>

Phillip G. wrote:

> > > If you are on some kind of Unix your favorite shell usually offers  
> > > Firstly:
> 
> –  
> Phillip “CynicalRyan” Gawlowski  
> [http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
> [http://clothred.rubyforge.org](http://clothred.rubyforge.org)
> 
> Eek! That was supposed to be My Special Law, _MY_ special law, I tell  
> you!
> 
> T/

Readline.readline does not have this capability.
