How to output my ruby commandline text in different colours

后端 未结 10 1906
青春惊慌失措
青春惊慌失措 2021-01-30 03:15

How can I make the puts commands I output from a commandline based ruby program colour? I would appreciated any references to how I call each different colour also.

Lets

10条回答
  •  旧巷少年郎
    2021-01-30 03:43

    My suggestion: The paint gem. It does not enforce string extensions and supports 256-colors (with fall-back mode for non-256-color terminals).

    Usage:

    puts Paint["I'm blue!", :blue]
    puts Paint["I'm dark blue if your terminal supports it!", "#000044"]
    

提交回复
热议问题