Bash: colored text (ANSI escapes) disappears in variable
by dlfw from LinuxQuestions.org on (#58DVP)
Hi!
I have a program printing out some colored text via ANSI escape codes.
When I capture the output of that program into a variable in bash (via backticks or $(...) ), the color information disappears and I just get the uncolored text when echo'ing it out. It's the same no matter if I use -e with echo or not.
I want to capture the output into a variable to use that in my bash prompt.
Any idea why this color information gets lost and how I can preserve the ANSI escapes printed by a separate program to use it in my bash prompt?


I have a program printing out some colored text via ANSI escape codes.
When I capture the output of that program into a variable in bash (via backticks or $(...) ), the color information disappears and I just get the uncolored text when echo'ing it out. It's the same no matter if I use -e with echo or not.
I want to capture the output into a variable to use that in my bash prompt.
Any idea why this color information gets lost and how I can preserve the ANSI escapes printed by a separate program to use it in my bash prompt?