Capturing colorized output to a bash variable

Viewed 2962

I want to capture the color output from git status in a variable and print it later.

So far I have come up to:

status=$(git status -s)
echo -e "$status"

The above script keeps the newline intact (thx to Capturing multiple line output into a Bash variable) but strips the color from the output.

Is there a way to keep the color in the variable and echo it?

3 Answers
Related