# Is there any way to save current job to a file in irb?

**URL:** <https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858>\
**Category:** Ruby\
**Created:** [September 15, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858 "2006-09-15T23:09:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuuul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ad7895/32.png) [@kuuul](https://www.ruby-forum.com/u/kuuul)\
**Post date:** [September 15, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858/1 "2006-09-15T23:09:18Z")

</div>

Or is there any tool to take place of it?

---

<div class="post-metadata">

**Author:** ![kuuul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ad7895/32.png) [@kuuul](https://www.ruby-forum.com/u/kuuul)\
**Post date:** [September 16, 2006, 12:41am UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858/2 "2006-09-16T00:41:33Z")

</div>

Kuang D. wrote:

> Or is there any tool to take place of it?

1. Please put your message in your message, rather than in the subject  
line.

2. Have you considered using a text editor to create a Ruby source file?  
It  
is way more efficient than trying to create a program in irb, then  
losing  
it.

“irb” is meant for testing things, not writing computer programs. As  
soon as  
you find yourself entering “do” or “{” into irb, it is time to open a  
text  
editor.

---

<div class="post-metadata">

**Author:** ![kuuul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ad7895/32.png) [@kuuul](https://www.ruby-forum.com/u/kuuul)\
**Post date:** [September 16, 2006, 1:19am UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858/3 "2006-09-16T01:19:35Z")

</div>

Kuang D. wrote:

> Or is there any tool to take place of it?

You can put this in your .irbrc:

def dump\_history(file=nil)  
if file  
File.open(file, “w”) do |f|  
f.puts IRB::ReadlineInputMethod::HISTORY.to\_a  
end  
else  
puts IRB::ReadlineInputMethod::HISTORY.to\_a  
end  
end

---

<div class="post-metadata">

**Author:** ![kuuul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ad7895/32.png) [@kuuul](https://www.ruby-forum.com/u/kuuul)\
**Post date:** [September 16, 2006, 2:01am UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858/4 "2006-09-16T02:01:39Z")

</div>

Kuang D. wrote:

> Or is there any tool to take place of it?

I use SCITE to test program fragments and can then save the code.

---

<div class="post-metadata">

**Author:** ![kuuul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ad7895/32.png) [@kuuul](https://www.ruby-forum.com/u/kuuul)\
**Post date:** [September 16, 2006, 6:56pm UTC](https://www.ruby-forum.com/t/is-there-any-way-to-save-current-job-to-a-file-in-irb/68858/5 "2006-09-16T18:56:50Z")

</div>

Michael W. Ryder wrote:

> Kuang D. wrote:
> 
> > Or is there any tool to take place of it?
> 
> I use SCITE to test program fragments and can then save the code.

There’s this, also

[http://irb-history.rubyforge.org/rdoc/](http://irb-history.rubyforge.org/rdoc/)
