How to output text to screen using standard ANSI colour codes
Created by Phil Gardner
last edited Jan 21 2018 by Phil Gardner
When displaying text on a screen in Linux/Unix, can send escape codes that will change the foreground or background colours.
Create constant identifiers in your programs for these sequences of escape characters and you have an easy and readable way to create colour output.
Can define your names directly in your program code, or alternatively create a reusable file e.g. “colours.h” to include from other source-code files.
Owls: (green and yellow)
Hello example: (red, green, blue, cyan)
Fruit machine: (red, yellow, amber)
More about colour codes on Wikipedia: