Swiftpack.co - mxcl/Chalk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by mxcl.
mxcl/Chalk 0.5.0
Terminal colors using Swift 5’s string interpolation extensions.
⭐️ 205
🕓 17 weeks ago
.package(url: "https://github.com/mxcl/Chalk.git", from: "0.5.0")


Terminal colors using Swift 5’s string interpolation extensions.

import Chalk  // @mxcl ~> 0.3

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

Styles, Backgrounds, Extended Colors etc.

// color, background & style can be specified all together or individually:
print("Foo \(string, color: .blue) bar")
print("Foo \(string, color: .blue, background: .yellow) bar")
print("Foo \(string, color: .blue, background: .yellow, style: .underline) bar")

// styles are an `OptionSet`:
print("Foo \(string, style: .underline) bar")
print("Foo \(string, style: [.underline, .bold]) bar")

// 256 color mode is supported:
print("Foo \(string, color: .extended(78) bar")


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.


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: .extended(15), background: .extended(UInt8(x)))", terminator: terminator)

Will give you:



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


Waiting on: @Carthage#1945.


Stars: 205
Last commit: 17 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Release Notes

17 weeks ago

Don’t output codes to non-terminals.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics