0

I found it really annoying when I use terminal that everything is in one color. I am looking for a way to print the output of my python code in a different color on the terminal console, so it will easier for me to distinguish the output of my code from the standard lines on terminal console (standard lines i.e. cd thisfile).

I am not looking for a way to specifically print colored python output to terminal like the following link

Print in terminal with colors using Python?

I am looking for a solution that everytime I open up terminal and run python scripts, the output will appear in a slightly different color. I want the effect to be permanent. Similar to turning on syntax on, once I turn it on, it is in the setting and I don't have to turn it on everytime I launch terminal.

And preferably, if possible, some code that I can just add directly to my .bash_profile that can help me achieve that, since I am not too familiar with bash scripting.

Community
  • 1
  • 1
mynameisJEFF
  • 4,073
  • 9
  • 50
  • 96

1 Answers1

2

the color in terminal usually is controlled by ANSI Escape:

http://en.wikipedia.org/wiki/ANSI_escape_code

You have to build the ANSI escape code together with your output text. Also you need to check if the escape codes are supported by your target terminal.

The link above has all information you needed.

this link should be useful too, for your bash tag:

http://misc.flogisoft.com/bash/tip_colors_and_formatting

Kent
  • 189,393
  • 32
  • 233
  • 301