Skip to content

Instantly share code, notes, and snippets.

@janxious
Created January 11, 2010 22:03
Show Gist options
  • Save janxious/274648 to your computer and use it in GitHub Desktop.
Save janxious/274648 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# this script can be used to find out what colours will look like on your terminal all in one go
module TermColours
@attributes = [0,1,4,5,7]
@foregrounds = 30..37
@backgrounds = 40..47
def self.print_all_attribute_foreground_background_combinations
@attributes.each do |attr|
print_attr_listing(attr)
end
end
def self.print_attr_listing(attr)
print_attr_header(attr)
@foregrounds.each do |fg|
print_for_foreground_set(attr, fg)
end
end
def self.print_attr_header(attr)
puts '----------------------------------------------------------------'
puts "ESC[#{attr};Foreground;Background"
end
def self.print_for_foreground_set(attr, fg)
@backgrounds.each do |bg|
print_color_entry(attr, fg, bg)
end
puts
end
def self.print_color_entry(attr, fg, bg)
print "\033[#{attr};#{fg};#{bg}m #{fg};#{bg}\033[0m"
end
end
TermColours.print_all_attribute_foreground_background_combinations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment