Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust pry colors

Tags:

ruby

pry

Edit: The faded gray is only an issue with version 0.9.7.3 and before. It has since been changed to a darker gray.

Pry has nice colorizing, but the value returned when an object is created or changed is a faded gray that I can barely see.

 u = User.new
 =>#<User...   <<<<<< This is what is barely readable.

I tried messing with values in .pryrc, but couldn't get this, or any other color for that matter, to change.

like image 564
Kyle Heironimus Avatar asked Oct 17 '11 19:10

Kyle Heironimus


1 Answers

Pry uses CodeRay for coloring, so you can put the following in your .pryrc file:

CodeRay.scan("example", :ruby).term # just to load necessary files

TERM_TOKEN_COLORS = {
    :symbol => '1;31' # will make symbols bolded and light red on my terminal
}

module CodeRay
    module Encoders
        class Term < Encoder
            # override old colors
            TERM_TOKEN_COLORS.each_pair do |key, value|
                TOKEN_COLORS[key] = value
            end
        end
    end
end

You can see here all values that can be customized (not sure which one exactly is the one you mentioned, but shouldn't be hard to track down): https://github.com/rubychan/coderay/blob/master/lib/coderay/encoders/terminal.rb

like image 168
deviousdodo Avatar answered Sep 21 '22 18:09

deviousdodo