Copy commands from ruby console

When you work on your ruby console typing some code, you often want to copy the commands you used.
This is not so easy because the commands are mixed in with their output:

ruby console

In order to print all commands you just typed in the ruby console, try this:

puts Readline::HISTORY.entries.split("exit").last

It prints only the commands and copying them is now easy.


comments powered by Disqus