Last active
June 7, 2024 05:04
-
-
Save tompng/dbe111d7d1175d83ebd47e9835e37e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return if ENV['WITHOUT_IRBRC'] | |
{ IRB: 'irb', Reline: 'reline', ReplTypeCompletor: 'repl_type_completor' }.each do |const_name, lib| | |
require lib | |
const = Object.const_get(const_name) | |
version = const::VERSION | |
dir = File.expand_path File.join(File.dirname(const.const_source_location(:VERSION).first), '../../') | |
if File.exist?(File.join(dir, '.git')) | |
Dir.chdir dir do | |
branch = `git branch`[/^\* .+/][2..] | |
rev = `git log --oneline -n 1 --pretty="format:%h"` | |
version = "#{branch}(#{rev})" | |
end | |
end | |
puts "\e[1m#{const_name}\e[m: #{version}" | |
rescue LoadError | |
end | |
begin; require 'irb/theme/rk2024'; rescue LoadError; end | |
IRB.conf[:COMPLETOR] = :type | |
if defined? ReplTypeCompletor | |
def ReplTypeCompletor.handle_exception(e) | |
puts e.full_message | |
@last_completion_error = e | |
end | |
end | |
# def Reline.debug_info | |
# ['debug', 'info'] | |
# end | |
Reline.core.add_dialog_proc(:debug, ->{ | |
contents = Reline.debug_info if Reline.respond_to?(:debug_info) | |
return if contents.nil? || contents.empty? | |
len = [screen_width / 8, 10].max | |
contents = contents.map { |line| line[0, len] } | |
pos = Reline::CursorPos.new(screen_width, -cursor_pos.y - 1) | |
Reline::DialogRenderInfo.new(pos:, contents:, height: contents.size, face: :completion_dialog) | |
}, nil) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment