Skip to content

Instantly share code, notes, and snippets.

@tdg5
Created June 9, 2015 23:16
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 tdg5/83814ec4b35cd93f8251 to your computer and use it in GitHub Desktop.
Save tdg5/83814ec4b35cd93f8251 to your computer and use it in GitHub Desktop.
Pry Hooks!
%w[
after_read
before_eval
after_eval
when_started
before_session
after_session
].each do |hook|
Pry.config.hooks.add_hook(hook.to_sym, "my_#{hook}_hook") do |_, _, _|
puts "hello from #{hook}"
end
end
Pry.commands.before_command("whereami") { |*args| puts "before whereami: #{args.inspect}" }
Pry.commands.after_command("whereami") { |*args| puts "after whereami: #{args.inspect}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment