ANSI 256 Color Test

alias colortest="python -c \"print('\n'.join([(' '.join([('\033[38;5;' + str((i + j)) + 'm' + str((i + j)).ljust(5) + '\033[0m') if i + j < 256 else '' for j in range(10)])) for i in range(0, 256, 10)]))\""
Terminal Color tester using python, works with py2 and 3
Sample Output
0     1     2     3     4     5     6     7     8     9    
10    11    12    13    14    15    16    17    18    19   
20    21    22    23    24    25    26    27    28    29   
30    31    32    33    34    35    36    37    38    39   
40    41    42    43    44    45    46    47    48    49   
50    51    52    53    54    55    56    57    58    59   
60    61    62    63    64    65    66    67    68    69   
70    71    72    73    74    75    76    77    78    79   
80    81    82    83    84    85    86    87    88    89   
90    91    92    93    94    95    96    97    98    99   
100   101   102   103   104   105   106   107   108   109  
110   111   112   113   114   115   116   117   118   119  
120   121   122   123   124   125   126   127   128   129  
130   131   132   133   134   135   136   137   138   139  
140   141   142   143   144   145   146   147   148   149  
150   151   152   153   154   155   156   157   158   159  
160   161   162   163   164   165   166   167   168   169  
170   171   172   173   174   175   176   177   178   179  
180   181   182   183   184   185   186   187   188   189  
190   191   192   193   194   195   196   197   198   199  
200   201   202   203   204   205   206   207   208   209  
210   211   212   213   214   215   216   217   218   219  
220   221   222   223   224   225   226   227   228   229  
230   231   232   233   234   235   236   237   238   239  
240   241   242   243   244   245   246   247   248   249  
250   251   252   253   254   255 

1
2012-10-26 07:43:06

These Might Interest You

  • Handles the color codes intended for 256-color terminals (such as xterm-(256)color and urxvt-unicode-256color), in addition to the standard 16-color ANSI forms. Overkill for strict ANSI output, see other options for something simpler.


    0
    sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    rcbarnes · 2012-06-12 11:20:46 0
  • Pre-packaged python script that comes with Debian/Ubuntu. Show Sample Output


    1
    colortest-python
    eikenberry · 2012-10-26 06:50:01 0
  • Removes ANSI color and end of line codes to the [{attr1};...;{attrn}m format.


    5
    sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g
    vaejovis · 2009-11-03 00:34:06 1
  • Remove ( color / special / escape / ANSI ) codes, from text, with sed Credit to the original folks who I've copied this command from. The diff here is: Theirs: [m|K] Theirs is supposed to remove \E[NUMBERS;NUMBERS[m OR K] This statement is incorrect in 2 ways. 1. The letters m and K are two of more than 20+ possible letters that can end these sequences. 2. Inside []'s , OR is already assumed, so they are also looking for sequences ending with | which is not correct. This : [a-zA-Z] This resolves the "OR" issue noted above, and takes care of all sequences, as they all end with a lower or upper cased letter. This ensures 100% of any escape code 'mess' is removed. Show Sample Output


    7
    sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"
    Zhoul · 2013-03-18 14:49:30 1

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?

commandlinefu.com 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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: