Created
October 24, 2011 08:23
-
-
Save potomak/1308580 to your computer and use it in GitHub Desktop.
Testing terminal colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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