Skip to content

Instantly share code, notes, and snippets.

@potomak
Created October 24, 2011 08:23
Show Gist options
  • Save potomak/1308580 to your computer and use it in GitHub Desktop.
Save potomak/1308580 to your computer and use it in GitHub Desktop.
Testing terminal colors
require 'rubygems'
require 'term/ansicolor'
COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
class String
include Term::ANSIColor
end
(0..15).each do |x|
(0..15).each do |y|
print " ".send("on_#{"intense_" if y > 7}#{COLORS[(y+x)%COLORS.size]}")
end
print "\n"
end
COLORS = {
:black => "tput setab 0",
:red => "tput setab 1",
:green => "tput setab 2",
:brown => "tput setab 3",
:blue => "tput setab 4",
:purple => "tput setab 5",
:cyan => "tput setab 6",
:lightgrey => "tput setab 7"
}
script = ""
script << "tput clear\n"
(0..7).each do |x|
(0..COLORS.size-1).each do |y|
script << "tput cup #{x} #{y*2}\n"
script << "#{COLORS[COLORS.keys[(y+x)%COLORS.size]]}\n"
script << "echo ' '\n"
end
end
system script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment