Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to write a program that utilizes all 256 of the Linux terminal's text colors. To date, however, I have only found a handful of color codes, which are in the format "\033[1;NUMmNUM\033[1;m". However, these escape codes only allow for two or three dozen colors, not the 256 that the Linux terminal supposedly allows for. How can I display those other colors in my curses application?

share|improve this question

You can have a look into TERM settings. It is possible it is set to lesser then capable string. To test colors you can run GNU's msgcat. Try e.g.:

echo $TERM
msgcat --color=test
msgcat --color=test

Or use @Ignacio Vazquez-Abrams's loop instead of msgcat.

For more information on how and what to set have a look at e.g.:

share|improve this answer

Stop using escape codes and use the setaf terminfo capability instead.

$ for i in $(seq 0 $(tput colors) ) ; do tput setaf $i ; echo -n "█" ; done ; tput setaf 15 ; echo
share|improve this answer
I only get eight colors that way, though, and the terminal supposedly supports 256. Where did all of the other colors go? – InkBlend Jun 12 '13 at 4:53
Your terminal only supports 8 colors then. Try another terminal. – Ignacio Vazquez-Abrams Jun 12 '13 at 4:54
I have tried LXTerm, Xterm, and the Linux terminal (both with and without tmux), and gotten the same result on all three. Are you sure that the Linux ttys themselves do not support 256 colors? – InkBlend Jun 12 '13 at 5:07
tput colors on my console resulted in 8. So I would say that this is not unique to you. – Ignacio Vazquez-Abrams Jun 12 '13 at 5:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.