1

I am printing some data to the screen and I want to color code certain values. For example, if the number is above 100, I want it to be red. I can do this by printing "\033[91m {}\033[00m" to the line before the number as explained in this post. I will need to go back to the 'default' color after that, however, but how do I know what the user's default color is? I have my background as black and the text shows up as white, but for another user who has white background and black text, setting the text color back to 'white' will break.

Is there a way, in Python to find the user's current 'default' text color?

Community
  • 1
  • 1
drjrm3
  • 4,474
  • 10
  • 53
  • 91
  • 1
    Possible duplicate of [how to get current terminal color pair in bash](http://stackoverflow.com/questions/28096697/how-to-get-current-terminal-color-pair-in-bash) – Arton Dorneles Mar 01 '16 at 17:48
  • And don't write terminal control codes until you know what kind of terminal you are writing to. Not all the world is a VT220! Much better to use a suitable termcap library to access its capabilities. – Toby Speight Mar 01 '16 at 18:30

1 Answers1

0

What I understood, is that u are asking to to get the default profile color of the user, of which u have change color of!

Eg: User is using 'Bright Green font color on Black background', you change it to 'Red font color on White background'. Now how to get/know the default colors and set them back to it!


You can use the sequence \033[0m in python [also directly for terminal (bash scripting) or command prompt (batch scripting) / powershell (ps scripting)

Divinemonk
  • 54
  • 6