Skip to content

Instantly share code, notes, and snippets.

@youpy
Created June 7, 2012 02:09
Show Gist options
  • Save youpy/2886089 to your computer and use it in GitHub Desktop.
Save youpy/2886089 to your computer and use it in GitHub Desktop.
convert text into 256 colors
# ref.
# http://www.frexx.de/xterm-256-notes/
$stdin.sync = true
filename = ARGV.shift
open(filename || '/dev/stdin') do |f|
f.each do |line|
line.unpack('U*') do |c|
print "\033[38;5;%im" % c
print "\033[48;5;%im" % c
print [c].pack('U')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment