Skip to main content

Color

extras.scala.io.syntax

extras-scala-io provides syntax to use scala.io.AnsiColor easily (The missing ones will be added later).

import extras.scala.io.syntax.color._

"Hello".blue
// res1: String = "\u001b[34mHello\u001b[0m"

"Hello".red
// res2: String = "\u001b[31mHello\u001b[0m"

"Hello".green
// res3: String = "\u001b[32mHello\u001b[0m"

"Hello".bold
// res4: String = "\u001b[1mHello\u001b[0m"

"Hello".underlined
// res5: String = "\u001b[4mHello\u001b[0m"

println("Hello".blue)
// Hello

println("Hello".red)
// Hello

println("Hello".green)
// Hello

println("Hello".bold)
// Hello

println("Hello".underlined)
// Hello

AnsiColor syntax support Example 1 AnsiColor syntax support Example 2

You can also chain them like this.

import extras.scala.io.syntax.color._

println("Hello".blue)
// Hello

println("Hello".blue.bold)
// Hello

println("Hello".blue.bold.underlined)
// Hello

println("Hello".underlined.bold.blue)
// Hello

AnsiColor syntax support Example 3