# File lib/pry/pry_class.rb, line 125
  def self.start(target=toplevel_binding, options={})
    target = Pry.binding_for(target)
    initial_session_setup

    # create the Pry instance to manage the session
    pry_instance = new(options)

    # save backtrace
    pry_instance.backtrace = caller

    # if Pry was started via binding.pry, elide that from the backtrace.
    pry_instance.backtrace.shift if pry_instance.backtrace.first =~ /pry.*core_extensions.*pry/

    # yield the binding_stack to the hook for modification
    pry_instance.exec_hook(:when_started, target, options, pry_instance)

    if !pry_instance.binding_stack.empty?
      head = pry_instance.binding_stack.pop
    else
      head = target
    end

    # Clear the line before starting Pry. This fixes the issue discussed here:
    # https://github.com/pry/pry/issues/566
    if Pry.config.auto_indent
      Kernel.print Pry::Helpers::BaseHelpers.windows_ansi? ? "\e[0F" : "\e[0G"
    end

    # Enter the matrix
    pry_instance.repl(head)
  end