-
Notifications
You must be signed in to change notification settings - Fork 1
/
pryrc
58 lines (48 loc) · 1.73 KB
/
pryrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# === EDITOR ===
Pry.editor = 'vim'
# === CUSTOM PROMPT ===
# This prompt shows the ruby version (useful for RVM)
Pry.prompt = [proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} > " }, proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " }]
# === Listing config ===
# Better colors - by default the headings for methods are too
# similar to method name colors leading to a "soup"
# These colors are optimized for use with Solarized scheme
# for your terminal
Pry.config.ls.heading_color = :magenta
Pry.config.ls.public_method_color = :green
Pry.config.ls.protected_method_color = :yellow
Pry.config.ls.private_method_color = :bright_black
begin
require 'hirb'
rescue LoadError
# Missing goodies, bummer
end
if defined? Hirb
# Dirty hack to support in-session Hirb.disable/enable
Hirb::View.instance_eval do
def enable_output_method
@output_method = true
Pry.config.print = proc do |output, value|
Hirb::View.view_or_page_output(value) || output.puts(value.ai)
end
end
def disable_output_method
Pry.config.print = proc { |output, value| output.puts(value.ai) }
@output_method = nil
end
end
end
# My pry is polite
Pry.config.hooks.add_hook(:after_session, :say_bye ) do
puts "bye-bye"
end
Pry::Commands.create_command "html5tidy" do
description "Print indented, colorized HTML from the input: html5tidy [ARGS]"
command_options requires_gem: ['nokogiri']
def process
@object_to_interrogate = args.empty? ? target_self : target.eval(args.join(" "))
cleaned_html = Nokogiri::XML(@object_to_interrogate,&:noblanks)
colorized_text = Pry.config.color ? CodeRay.scan(cleaned_html, :html).term : cleaned_html
output.puts colorized_text
end
end