forked from pyroscope/rtorrent-ps
-
Notifications
You must be signed in to change notification settings - Fork 13
/
term-256color.py
executable file
·44 lines (34 loc) · 977 Bytes
/
term-256color.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python
# Copyright (C) 2006 by Johannes Zellner, <[email protected]>
# modified by [email protected] to fit my output needs
# modified by [email protected] to fit my output needs
# [email protected] added a final "tput init", and changed the output format
import os
import sys
def echo(msg):
os.system('echo -n "' + str(msg) + '"')
def out(n):
os.system("tput setab " + str(n) + "; echo -n " + ("\"% 4d\"" % n))
os.system("tput setab 0")
if os.getenv("TERM") in ("xterm", "screen"):
os.putenv("TERM", os.getenv("TERM") + "-256color")
try:
# normal colors 1 - 16
os.system("tput setaf 16")
for n in range(8):
out(n)
echo("\n")
for n in range(8, 16):
out(n)
echo("\n")
echo("\n")
y=16
while y < 256:
for z in range(0,18):
out(y)
y += 1
if y >= 256: break
echo("\n")
echo("\n")
finally:
os.system("tput init")