Issue
I'm trying to add color output to my errors in a bash script that I have running on a mac. The problem is the colors are not working. I created the simplest of scripts to demonstrate that it does not work:
#!/bin/bash
echo -e "\e[1;31m This is red text \e[0m"
However, when i run it, I see no colors at all, as shown in this image. The color output of the ls command is working fine however.
Solution
OSX ships with an old version of Bash that does not support the \e
escape character. Use \x1B
or update Bash (brew install bash
).
Even better, though, would be to use tput
.
Answered By - danemacmillan Answer Checked By - Clifford M. (WPSolving Volunteer)