Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2019 22:56
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Decorating Command Line Output With DefaultStringInterpolation
enum ASCIIColor: String {
case black = "\u{001B}[0;30m"
case red = "\u{001B}[0;31m"
case green = "\u{001B}[0;32m"
case yellow = "\u{001B}[0;33m"
case blue = "\u{001B}[0;34m"
case magenta = "\u{001B}[0;35m"
case cyan = "\u{001B}[0;36m"
case white = "\u{001B}[0;37m"
case `default` = "\u{001B}[0;0m"
extension DefaultStringInterpolation {
mutating func appendInterpolation<T: CustomStringConvertible>(_ value: T, color: ASCIIColor) {
// "\("only this string will be green!", color: .green)"
Copy link

It does not work for me (XCode 13, Swift 5.5)

I have this in consol:
�[0;32monly this string will be green!�[0;0m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment