How to adjust pry colors

夙愿已清 提交于 2019-12-03 12:29:44

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/7798795/how-to-adjust-pry-colors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!