Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active May 12, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/c42f866040db28af95a83823cc2aff1e to your computer and use it in GitHub Desktop.
Save havenwood/c42f866040db28af95a83823cc2aff1e to your computer and use it in GitHub Desktop.
A snippet to add to your .pryrc so refinements work at top level
Tempfile.new('pry-binding').tap do |binding_chord|
binding_chord << 'Pry.toplevel_binding = binding'
binding_chord.close
load binding_chord.path
ensure
binding_chord.unlink
end
# derived from al203-cr's solution in the #ruby IRC channel
Pry.hooks.add_hook :when_started, :context_switch do |_output, _binding, pry|
pry.binding_stack = [TOPLEVEL_BINDING]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment