helm/dev/+rbenv/.pryrc

47 lines
1.2 KiB
Plaintext
Raw Normal View History

2014-10-09 15:30:43 -07:00
# Pry config
if ['dumb', 'emacs'].include? ENV['TERM']
2014-12-13 16:35:07 -08:00
Pry.config.color = false
Pry.config.pager = false
Pry.config.auto_indent = false
end
2014-10-09 15:30:43 -07:00
# Show ruby version/patch level in prompt
prompt = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
Pry.config.prompt = [
proc { |obj, nest_level, _| "#{prompt} (#{obj}):#{nest_level} > " },
proc { |obj, nest_level, _| "#{prompt} (#{obj}):#{nest_level} * " }
]
2014-10-25 13:38:19 -07:00
if defined?(PryByebug)
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
end
# Repeat last command with enter
2014-12-13 16:35:07 -08:00
Pry::Commands.command /^$/, 'repeat last command' do
2014-10-25 13:38:19 -07:00
_pry_.run_command Pry.history.to_a.last
end
2014-10-09 15:30:43 -07:00
# https://github.com/michaeldv/awesome_print/
# $ gem install awesome_print
2014-10-25 13:38:19 -07:00
begin
require 'awesome_print'
AwesomePrint.defaults = { indent: -2 }
AwesomePrint.pry!
rescue LoadError
end
2014-10-09 15:30:43 -07:00
## Benchmarking
# Inspired by <http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick/123834#123834>.
def time(repetitions = 100, &block)
require 'benchmark'
Benchmark.bm { |b| b.report { repetitions.times(&block) } }
end
def run(file)
require "#{Dir.pwd}/#{file}"
end