how do you change the syntax highlighting in Pry? Use Pry theme

Colours in Pry not quite how you want them?

Here’s how to change them:

[~]$ gem install pry-theme
[~]$ pry
Can't find `Pry.config.theme` definition in your `~/.pryrc`.
Using "pry-classic" theme now.
[1] pry(main)> pry-theme -l

[github]
Based on github theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

[monokai]
Based on Wimer Hazenberg's theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

* [pry-classic]
Default Pry theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

To get rid of the warning message create a pryrc file and add a theme, e.g.

Pry.config.theme="pry-modern"

https://github.com/kyrylo/pry-theme

On the Mac, another alternative is to just change your Terminal preferences.

Questions on pry?

Hang out at #pry on irc.freenode.net

Leave a Reply

Your email address will not be published. Required fields are marked *