module Kernel

def _load_looksee

def _load_looksee
  require 'looksee'
  Looksee.rename :ls_looksee
  Looksee.editor = '.emacsclient +%l %f' # e.g. [].ls1.edit :to_set
end

def irb!

def irb!
  return unless ENV['IRB_was_started'].nil?
  ENV['IRB_was_started'] = 'true'
  irb3(2)
end

def irb1

def irb1
  ENV['IRB2_should_start'] = 'true'
end

def irb2

def irb2
  if ENV['IRB2_should_start'] == 'true'
    ENV['IRB2_should_start'] = nil
    irb3(2)
  end
end

def irb3(caller=1)

def irb3(caller=1)
  require 'binding_of_caller'
  binding.of_caller(caller)._irb
end

def ls1(*args)

def ls1(*args)
  _load_looksee unless defined? Looksee
  Looksee[self, *args, :noprivate]
end

def ls2(*args)

def ls2(*args)
  _load_looksee unless defined? Looksee
  Looksee[self, *args]
end

def notify_send(msg)

def notify_send(msg)
  system("notify-send \"#{msg}\"") if system 'which notify-send &>/dev/null'
  system('aplay "#{__dir__}/drip.wav" &>/dev/null') if system 'which aplay &>/dev/null'
  warn "#{msg}"
end

def pry!(host: nil, port: 9876, state: false)

运行 pry! 会被拦截, 且只会被拦截一次.
def pry!(host: nil, port: 9876, state: false)
  # You can use environment variables SHOW_GLOBAL_VARIABLES,
  # HIDE_INSTANCE_VARIABLES and HIDE_LOCAL_VARIABLES
  # to customise the kind of variables shown.
  require_relative '../pry-state' if state
  return unless ENV['Pry_was_started'].nil?
  ENV['Pry_was_started'] = 'true'
  pry3(2, host: host, port: port)
  # 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空.
end

def pry1

def pry1
  ENV['Pry2_should_start'] = 'true'
end

def pry2(host: nil, port: 9876)

def pry2(host: nil, port: 9876)
  if ENV['Pry2_should_start'] == 'true'
    ENV['Pry2_should_start'] = nil
    pry3(2, host: host, port: port)
  end
end

def pry3(caller=1, host: nil, port: 9876)

起成 pry3 这个名字,也是为了方便直接使用。
等价于默认的 binding.pry, 会反复被拦截。
def pry3(caller=1, host: nil, port: 9876)
  host = '0.0.0.0' if Pryx::Background.background?
  require 'binding_of_caller'
  binding.of_caller(caller)._pry(host: host, port: port)
end

def reirb!

def reirb!
  ENV['IRB_was_started'] = nil
end

def repry!

在 pry! 之前如果输入这个,会让下次执行的 pry! 被拦截一次, 而不管之前是否有执行过 pry!
def repry!
  ENV['Pry_was_started'] = nil
end