You can use ~/.irb-history
for this purpose. So, the following can be used (you must be knowing how to do this, but this is only for reference):
tail -fn0 ~/.irb-history # for tailing
cat ~/.irb-history | grep something # for searching
Note that, you might have both the files: ~/.irb-history
and ~/.irb_history
, and any one of them can be more up to date than the other. I have not been able to resolve this mystery yet. So, use the one you find more suitable for yourself.
UPDATE: You can access history in a variable using the following logic (it took me a while to read the code Pry uses, try edit history
inside pry):
def pry_history
arr = []
history = Pry::History.new
history.send(:read_from_file) do |line|
arr.push line.chomp
end
arr
end
Now, you can simply call pry_history
to get an array of pry's history. You can further save it inside your .pryrc
configuration file and use it whenever you want in pry.