6
votes

I'm using the pry REPL for ruby, and its rails plugin (the gem pry-rails). Currently pry has a global history for all projects. Is it possible to configure it such that each rails project will have its own history file?

2

2 Answers

7
votes

There are instructions for this on the Pry wiki under history, here's the relevant part for what you want:

Example: Put the history file in the current directory, for a separate history per-project:

Permanently (in a .pryrc file)

Pry.config.history.file = ".pry_history"
1
votes

create a new class like this

class Utils
  def self.pry_history
    path = Pry.config.history.file
    valuef = `cat -n #{path}`
    print valuef
  end
end

then in your pry console you can do

pry(main)> Utils.pry_history