Skip to content

Instantly share code, notes, and snippets.

@cnosuke
Created December 12, 2013 10:20
Show Gist options
  • Save cnosuke/7925865 to your computer and use it in GitHub Desktop.
Save cnosuke/7925865 to your computer and use it in GitHub Desktop.
Pry.config.prompt = [
proc {|target_self, nest_level, pry|
nested = (nest_level.zero?) ? '' : ":#{nest_level}"
"[#{pry.input_array.size}] #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}(#{Pry.view_clip(target_self)})#{nested}> "
},
proc {|target_self, nest_level, pry|
nested = (nest_level.zero?) ? '' : ":#{nest_level}"
"[#{pry.input_array.size}] #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}(#{Pry.view_clip(target_self)})#{nested}* "
}
]
begin
require 'hirb'
rescue LoadError
# Missing goodies, bummer
end
if defined? Hirb
# Slightly dirty hack to fully support in-session Hirb.disable/enable toggling
Hirb::View.instance_eval do
def enable_output_method
@output_method = true
@old_print = Pry.config.print
Pry.config.print = proc do |output, value|
Hirb::View.view_or_page_output(value) || @old_print.call(output, value)
end
end
def disable_output_method
Pry.config.print = @old_print
@output_method = nil
end
end
Hirb.enable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment