How to activate ANSI shell script colors in Visual Studio Codium terminals?

92 Views Asked by At

I am using Visual Studio Codium on MacOs.

When I open a terminal and enter echo "\033[31mThis is red font.\033[0m"I get a nice red text.

When I run a shell script reading

#!/bin/bash
echo "\033[31mThis is red font.\033[0m"

in the same terminal I get \033[31mThis is red font.\033[0m

What can I do to have the shell scripts produce colored text in the terminal window?

1

There are 1 best solutions below

0
On BEST ANSWER

To cause escape sequences to interpreted, the -e option can be used:

echo -e .....

As long as you use the bash-builtin echo, this should be portable.