Episode #467

ANSI Colors in Command Line Output

Series: Command Line Swift

18 minutes
Published on November 5, 2020

This video is only available to subscribers. Get access to this video and 584 others.

I always like it when command line programs offer colored output, which helps to discern between various stages of output, highlight errors and other important information. This is done with ANSI color codes, which are a somewhat archaic technique, but we can implement a nice wrapper to make it easy to work with in Swift.

Episode Links

Node that Xcode does not support this, so if you run the apps in Xcode you'll see the raw escape codes. To see the colored output you'll need to run the app in a Terminal window.