Article 58DVP Bash: colored text (ANSI escapes) disappears in variable

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?latest?d=yIl2AUoC8zA latest?i=-9-6kgbos7k:lguV1FUo8ZY:F7zBnMy latest?i=-9-6kgbos7k:lguV1FUo8ZY:V_sGLiP latest?d=qj6IDK7rITs latest?i=-9-6kgbos7k:lguV1FUo8ZY:gIN9vFw-9-6kgbos7k
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments