    # File lib/chef/shef/ext.rb, line 37
          def ensure_session_select_defined
            # irb breaks if you prematurely define IRB::JobMangager
            # so these methods need to be defined at the latest possible time.
            unless jobs.respond_to?(:select_session_by_context)
              def jobs.select_session_by_context(&block)
                @jobs.select { |job| block.call(job[1].context.main)}
              end
            end

            unless jobs.respond_to?(:session_select)
              def jobs.select_shef_session(target_context)
                session = if target_context.kind_of?(Class)
                  select_session_by_context { |main| main.kind_of?(target_context) }
                else
                  select_session_by_context { |main| main.equal?(target_context) }
                end
                Array(session.first)[1]
              end
            end
          end