-
-
Save 2called-chaos/2994346579729acb17d3b03b1802e6d3 to your computer and use it in GitHub Desktop.
My pryrc file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pry.config.editor = "subl" | |
Pry.hooks.add_hook(:before_eval, "runtime_start") do |output, pry| | |
pry.instance_variable_set(:"@x_runtime_start", Time.now) | |
end | |
Pry.hooks.add_hook(:after_eval, "runtime_end") do |output, pry| | |
pry.instance_variable_set(:"@x_runtime_end", Time.now) | |
end | |
Pry.config.print = proc do |output, value, _pry_| | |
rts = _pry_.instance_variable_get(:"@x_runtime_start") | |
rte = _pry_.instance_variable_get(:"@x_runtime_end") | |
_pry_.instance_variable_set(:"@x_runtime_start", false) | |
_pry_.instance_variable_set(:"@x_runtime_end", false) | |
if rts && rte | |
rt = (rte - rts) | |
rtms = (rt * 1000.0).round | |
rtus = (rt * 1000.0 * 1000.0).round | |
rtf = rtms.zero? ? "#{rtus}µs" : "#{rtms}ms" | |
end | |
_pry_.pager.open do |pager| | |
pager.print "\e[30m#{rtf}\e[0m #{_pry_.config.output_prefix}" | |
Pry::ColorPrinter.pp(value, pager, output.width) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment