ruby / ruby/irb

Allow disabling dialog colors

Open
#327 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

Description

I'm unsure if this falls under Reline, or IRB, if I have filed this in the wrong repository do let me know and I'll move it.

IRB allows us to disable colors using IRB.conf[:USE_COLORIZE] = false, however - after the dialog introduction in Ruby 3.1 (or Reline 0.3.0) - the dialog is still colored even though --nocolorize or the config above is present.

image

I would expect that the colors are disabled if the irb configuration is present, or by any other means if possible.

Result of irb_info

irb(main):002:0> irb_info
=>
Ruby version: 3.1.0
IRB version: irb 1.4.1 (2021-12-25)
InputMethod: ReidlineInputMethod with Reline 0.3.0
.irbrc path: /Users/teo/.irbrc
RUBY_PLATFORM: x86_64-darwin21
LANG env: en_US.UTF-8
LC_ALL env: en_US.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

kitty

Setting Files

~/.irbrc:

require "irb"
require "irb/completion"

ENV["TERM"] = "xterm"

IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] =
  if defined?(Rails) && Rails.root
    Rails.root.join("tmp", "history.rb")
  else
    File.expand_path("~/.history.rb")
  end
IRB.conf[:USE_COLORIZE] = false

if defined?(Rails)
  ActiveSupport::LogSubscriber.colorize_logging = false
end

class Object
  def interesting_methods
    case self.class
    when Class
      self.public_methods.sort - Object.public_methods
    when Module
      self.public_methods.sort - Module.public_methods
    else
      self.public_methods.sort - Object.new.public_methods
    end
  end
end

def capture_exception(&block)
  block.call
rescue => exception
  exception
end

def time(&block)
  t0 = Time.now
  block.call
  puts Time.now - t0
end

def ri(*args)
  help(*args)
end

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the colored dialog with the reported Ruby 3.1, Reline 0.3.0 setup and the ~/.irbrc setting IRB.conf[:USE_COLORIZE] = false; compare it with --nocolorize. Trace how IRB.conf and the dialog's color handling interact, then verify that both configuration paths disable dialog colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.