Show numerical values for each of the 256 colors in bash

for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done
Same as, but for bash. This will show a numerical value for each of the 256 colors in bash. Everything in the command is a bash builtin, so it should run on any platform where bash is installed. Prints one color per line. If someone is interested in formatting the output, paste the alternative.

By: scribe
2010-06-19 02:14:42

4 Alternatives + Submit Alt

What Others Think

hmm, needs to set a background color so it doesn't blend in so badly with my shell's bg color.
kaedenn · 604 weeks and 1 day ago
I'd echo the code itself rather than "Test". See For a 256 color palette you can hover over to get the code see:
pixelbeat · 603 weeks and 6 days ago
More compact output all on one line: for code in {0..255}; do echo -en "\e[38;05;${code}m $code:"; done
dattaway · 603 weeks and 4 days ago
The pretty part of the table, nicely formatted: for line in {0..5}; do for col in {0..39}; do code=$(( $col * 6 + $line + 16 )); printf $'\e[38;05;%dm %03d' $code $code ;done; echo ;done
bartonski · 601 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: