janlelis / irbtools

Improvements for Ruby's IRB console 💎︎
MIT License
920 stars 27 forks source link

How to modify output colors? #42

Closed TLINDEN closed 6 years ago

TLINDEN commented 6 years ago

So, in the fancy_irb page it says something about DEFAULT_OPTIONS, which is undefined in my irb session and if I configure it via .irbrc it doesn't have any effect. The problem is, that the rocket output lines are printed in yellow (on a white terminal) and are thus unreadable.

I tried, for example:

Irbtools.replace_library_callback :fancy_irb do
  FancyIrb.start :colorize => nil
end

but this doesn't seem to get called.

janlelis commented 6 years ago

Hi and thanks for the feedback!

How to adjust the colors depends on what exact output should be changed. By default, one thing which is yellow are Ruby symbols (which is caused by the current Wirb default color schema). If this is your problem, try to change it like this:

# in .irbrc, instead of require "irbtools"
require 'irbtools/configure'
Irbtools.add_library_callback "wirb/wp" do
  Wirb.load_schema(:ultra)
end
Irbtools.start

If this does not solve your issues, please elaborate and/or post a screenshot.

TLINDEN commented 6 years ago

Yes, symbols are the problem, but the code above doesn't have any effect either.

Here's my actual .irbrc:

# -*-ruby -*-

require 'irb/completion'
require 'irb/ext/save-history'
require 'irbtools/configure'

require "awesome_print"
AwesomePrint.irb!
# see also .aprc

IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
IRB.conf[:AUTO_INDENT] = true

$LOAD_PATH.unshift('.')

require 'irbtools'

def history(inc=nil)
  if inc then
    puts Readline::HISTORY.entries.grep(inc).sort * "\n"
  else
    puts Readline::HISTORY.entries * "\n"
  end
end

Irbtools.add_library_callback "wirb/wp" do
  Wirb.load_schema(:ultra)
end

Irbtools.start

And here's how it looks: yellow

PS: I also tried to disable awesome_print with no effect as well

janlelis commented 6 years ago

Please try replacing require "irbtools" with require "irbtools/configure"

TLINDEN commented 6 years ago

Thanks a lot, that solved it! Love it :)

janlelis commented 6 years ago

Great to hear!

Btw: I am also using a white background, so I'll look into making a more general purpose default theme for Wirb some time.