Thursday, November 11, 2010

ansi color (with python)

#! /magnum/oss/bin/python
def printC(bg,fg):
print "\033[05;"+bg+";"+fg+"mABC"+"\033[0m"
mystr=""
attrib=[0,1,4,5,7,8]
for i in attrib:
mystr+="\033[%dm%d\033[0m " % (i,i)
print mystr
mystr="\n\n"
for i in range (40,48):
mystr="%d:" % i
for j in range (30,38):
fg=str(j)
mystr= mystr + (" \033[1;%d;%dm%d\033[0m" % (i,j,j))
print mystr

#EOF

%color.py
0 1 4 5 7 8
40: 30 31 32 33 34 35 36 37
41: 30 31 32 33 34 35 36 37
42: 30 31 32 33 34 35 36 37
43: 30 31 32 33 34 35 36 37
44: 30 31 32 33 34 35 36 37
45: 30 31 32 33 34 35 36 37
46: 30 31 32 33 34 35 36 37
47: 30 31 32 33 34 35 36 37

No comments: