MacOs Terminal zsh - cannot use ansi

Zsh provides a very easy way to add color to your prompt; you don't need Escape codes.

PROMPT='%F{blue}%n%f %#'
  • %F = Sets foreground color defined in braces {}
  • %f = resets to default foreground color
  • %n = username

You can even access the 256 color pallet for your colors by specifying the number within the braces - %F{146} for “light steel blue“

For a detailed list of all the codes and what they do, see the official Zsh Documentation - Chapter 13 Visual Effects.