We know X11 has rgb.txt file that defines over 700 colors. Is there a similar file that defines the 256 colors (ie., hex code plus name) used in most terminal apps ?
sample lines:
255 250 250 snow 248 248 255 ghost white 248 248 255 GhostWhite We know X11 has rgb.txt file that defines over 700 colors. Is there a similar file that defines the 256 colors (ie., hex code plus name) used in most terminal apps ?
sample lines:
255 250 250 snow 248 248 255 ghost white 248 248 255 GhostWhite Why make things so complicated? Use ANSI-colors instead.
Some Python code for you
#!/bin/env python3 CSI = "\x1B[" fg='3' bg='4' mode='5' def setRGB(fgbg, r, g=0, b=0, mde='2'): """ set a color on fg or bg mde=2 r;g;b mde=5 r - 0-255, for 256 color mode """ if mde=='5': return f"{CSI}{fgbg}8;{mde};{r}m" return f"{CSI}{fgbg}8;{mde};{r};{g};{b}m" if __name__ == "__main__": import sys for n in range(256): print(setRGB(fg,n,mde=mode)+setRGB(bg,254-n,mde=mode)+f' {n:3} ',end='') if (n+1)%16==0: print(f'{CSI}0m') print(f'{CSI}0m') If you intend to use it in windows CMD, add these lines after main:
# Windows (i.e "nt"), needs ANSI initialized: import os if os.name=="nt": os.system("") # magic to init ANSI -sequences (= load ANSI.SYS for oldish CMD?)