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
require 'pp'

# make it more pry-like
IRB.conf[:PROMPT][:ALPHA] = {
  :PROMPT_I => "[%n] %N(%m)> ",
  :PROMPT_S => "[%n] %N(%m)> ",
  :PROMPT_C => "[%n] %N(%m)* ",
  :RETURN => "=> %s\n",
}
IRB.conf[:PROMPT_MODE] = :ALPHA

# use type completor if available
begin
  require "repl_type_completor"
  IRB.conf[:COMPLETOR] = :type
rescue LoadError
end

if defined?(Reline::Face) # https://github.com/ruby/irb/issues/328
  Reline::Face.config(:completion_dialog) do |conf|
    conf.define :default, foreground: :black, background: :cyan
    conf.define :enhanced, foreground: :black, background: :magenta
    conf.define :scrollbar, foreground: :white, background: :blue
  end
end


## utility functions

def pbcopy(str=nil)
  str = yield if block_given?
  IO.popen(%w[pbcopy], 'w') {|io| io.write str }
end

def tic; @_tic = Time.now; end
def toc; Time.now - @_tic; end

# IRB.conf[:AUTO_INDENT] = true
# IRB.conf[:EVAL_HISTORY] = 1000
# IRB.conf[:SAVE_HISTORY] = 1000
# IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"

# shut irb up
# IRB.conf[:PROMPT][ IRB.conf[:PROMPT_MODE] ][:RETURN] = ''

# require 'wirble'
# def pc(*ary)
#   ary.each do |obj|
#     puts Wirble::Colorize.colorize(obj.inspect)
#   end
# end

# def history
#   Readline::HISTORY.to_a
# end

irbrc_local = File.expand_path(".irbrc.local", __dir__)
require irbrc_local if File.exist?(irbrc_local)