Created
June 7, 2012 02:09
-
-
Save youpy/2886089 to your computer and use it in GitHub Desktop.
convert text into 256 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
# 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