How to output my ruby commandline text in different colours

后端 未结 10 1766
青春惊慌失措
青春惊慌失措 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 04:03

    I find the Colored gem to be the easiest and cleanest to use.

    puts "this is red".red
    puts "this is red with a blue background (read: ugly)".red_on_blue
    puts "this is red with an underline".red.underline
    puts "this is really bold and really blue".bold.blue
    logger.debug "hey this is broken!".red_on_yellow 
    

提交回复
热议问题