I'm trying to add colors to a bash script I'm writing, and I'm following this tutorial.
Wehenver I copy/paste and run in my OSX terminal (OSX 11.3.1)
#! /usr/bin/env bash
RED="\e[31m"
GREEN="\e[32m"
ENDCOLOR="\e[0m"
echo -e "${RED}This is some red text, ${ENDCOLOR}"
echo -e "${GREEN}And this is some green text${ENDCOLOR}"
I get the proper output, with the colored text. However, after saving this in a file, colors.command
and run chmod +x colors/command
and then try to run the script either by double clicking it, or ./colors.command
the output I get in my terminal is:
\e[31mThis is some red text, \e[0m
\e[32mAnd this is some green text\e[0m
How can I fix this so that my script outputs the colors properly when run?