Orange terminal text

11,666

Solution 1

Because you can't just make up a code and assign it a color name because you want it to exist?

Your terminal only has the colors it has available. (Many go to 88 or 256 at this point but those are extended codes.)

Also technically you don't know that 36 (for example) is actually cyan. You just know you are asking for the color in that slot (the terminal can have any color in that slot it wants).

Solution 2

Escape codes come from the days where a computer couldn't display more than 8 different colours simultaneously - They had to pick what these 8 colours (8 foreground, 8 background for a total of "16 colours") were, and orange was not one of the choices when they selected them.

EDIT: Please note that these are colours defined in the ANSI standard - there are terminals out there that have colours other than ANSI, although ANSI is most widespread (and these days ubiquitous) - Also users may manipulate their terminals to display other colour schemes.

Share:
11,666
Atomiklan
Author by

Atomiklan

Updated on July 25, 2022

Comments

  • Atomiklan
    Atomiklan almost 2 years

    Why do you never see orange terminal text?

    For example in python:

    class text_color:
            black = '\033[30m'
            red = '\033[31m'
            green = '\033[32m'
            yellow = '\033[33m'
            blue = '\033[34m'
            magenta = '\033[35m'
            cyan = '\033[36m'
            white = '\033[37m'
    
    # START MAIN
    print text_color.yellow + "YAY"
    

    Why doesn't this below work? Why dont you ever see orange as an option?

    orange = '\033[40m'
    

    * SOLUTION *

    I didn't really understand terminals at the start of this problem. If you are in my same shoes, please reference this site to answer your question:

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

    • n. m.
      n. m. over 8 years
      Because orange is not in the list of ANSI terminal colors.
    • 5gon12eder
      5gon12eder over 8 years
      Because that last escape sequence (re)sets the background color to 0. Why should it set the foreground to orange?
    • Atomiklan
      Atomiklan over 8 years
      Hmm I guess the source I got that from was incorrect then. They said that was the code for orange. Ok so if it is not in the list of ANSI terminal colors, then is there any way to do it? I know I have seen it before on say FreeBSD.
    • SteJ
      SteJ over 8 years
      As mentioned by @5gon12eder, you can choose custom colours, but they are then no longer ANSI and so you can't guarantee the colour will display as you intended on all systems
    • Brad
      Brad about 2 years
      OMG THANK YOU! Been trying to find that website again for ages as it stopped showing it in my search results. FYI: I use orange all the time and this is how I got here.
  • 5gon12eder
    5gon12eder over 8 years
    The terminal emulator on an X window system should allow you to associate arbitrary colors with the constants, however. You can have 3 be orange, if you like.
  • Atomiklan
    Atomiklan over 8 years
    Can you point me to a resource or show me an example of how to get orange?
  • SteJ
    SteJ over 8 years
    @5gon12eder is also right; note however that this does tie you down in that the colour will only display correctly when using Xterm (or similar) and not when you're using the console
  • Atomiklan
    Atomiklan over 8 years
    Hmm interesting, so what is the recommended method of assigning terminal colors?
  • SteJ
    SteJ over 8 years
    @Atomiklan: Is This what you're looking for?
  • chepner
    chepner over 8 years
    There is no "recommended" method; it varies by terminal emulator.
  • 5gon12eder
    5gon12eder over 8 years
    @Atomiklan It depends on what emulator you use. Check here for the one that comes with Gnome. This is something the user will set up according to her personal preferences, however. Not something your program would do.
  • Atomiklan
    Atomiklan over 8 years
    Hmm for years I have written BASH scripts that would output errors, warnings, etc upon running when applicable. I would always color those appropriately so they are easy to see in the terminal. I'm now getting into OOPython and trying to do the same. I have always used red yellow green. Just thought it would be nice to include orange too. I guess in the end though, I have been going about this conceptually all wrong.
  • Atomiklan
    Atomiklan over 8 years
    I generally login to my servers via putty, a directly attached monitor, or via the console window in ESXi. I guess I have never really tested it, but are you suggesting that each method I use to login, the colors could be controlled differently (putty vs monitor), or that there is potentially a difference between operating systems ie my script run on Ubuntu will look different from Fedora?
  • SteJ
    SteJ over 8 years
    You may find that each of those different logins will produce different colours - you'd need to configure your custom colours on all three different consoles.
  • Atomiklan
    Atomiklan over 8 years
    That's annoying... You would have thought that by default green means green. So when you tell a program or script to output text in green all Linux based systems would understand that... Seems like a pretty simple concept to me. Now sure if someone changes the default then ok.
  • SteJ
    SteJ over 8 years
    I'm not sure if it suits your application, but I believe you can code custom colour palletes using the curses library (it's been a long time, so if that's wrong please tell me and I'll remove this comment)?
  • chepner
    chepner over 8 years
    Just to note, "\033[38;5;214m" would be a code for one shade of orange if supported by the terminal.
  • Atomiklan
    Atomiklan over 8 years
    Seems to work chepner. Can you explain a little more about the support side of things. ie which terminals generally support it. Does anyone know the official resource or an excellent guide for these escape sequences. I have been just going off regurgitated command line syntax.
  • Atomiklan
    Atomiklan over 8 years