Skip to content
Terminal colors using Swift 5’s string interpolation extensions.
Branch: master
Clone or download
Latest commit c9a587c Feb 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore mxcl.github.io -> mxcl.dev Feb 28, 2019
.travis.yml [ci] Test Builds Feb 23, 2019
Chalk.swift
LICENSE
Package.swift .some Feb 23, 2019
README.md

README.md

Chalk

Terminal colors using Swift 5’s string interpolation extensions.

import Chalk  // @mxcl ~> 0.3

let colorString = "blue"
print("Here’s \(colorString, color: .blue)!")

Name

Chalk by @sindresorhus is an extremely famous Node package for the same purpose. Open source is facilitated by naming connections, we picked the same name to enable those mental connections.

This package is called Chalk, or mxcl/Chalk or Chalk for Swift when disambiguating.

Support mxcl

Hey there, I’m Max Howell, a prolific producer of open source and probably you already use some of it (I created brew). I work full-time on open source and it’s hard; currently I earn less than minimum wage. Please help me continue my work, I appreciate it 🙏🏻

Other ways to say thanks.

Demo

If you have swift-sh:

$ swift sh <<EOF
import Foundation
import Chalk  // @mxcl ~> 0.3

for x in 0..<256 {
    let cell = " \(x)".padding(toLength: 5, withPad: " ", startingAt: 0)
    let terminator = (x + 3).isMultiple(of: 6) ? "\n" : ""
    print("\(cell, color: 15, background: UInt8(x))", terminator: terminator)
}
EOF

Will give you:

Installation

SwiftPM:

package.append(.package(url: "https://github.com/mxcl/Chalk.git", from: "0.1.0"))

Carthage:

Waiting on: @Carthage#1945.

You can’t perform that action at this time.