diff options
| author | Silvio Rhatto <rhatto@riseup.net> | 2013-01-13 15:37:49 -0200 |
|---|---|---|
| committer | Silvio Rhatto <rhatto@riseup.net> | 2013-01-13 15:37:49 -0200 |
| commit | 454c6e3c77b3db507ee81875219089047fc2d5a3 (patch) | |
| tree | 34ea351902ddd6094bc0a96a65b4bc07e9ee83d8 /misc/term-color | |
| download | scripts-454c6e3c77b3db507ee81875219089047fc2d5a3.tar.gz scripts-454c6e3c77b3db507ee81875219089047fc2d5a3.tar.bz2 | |
Initial import
Diffstat (limited to 'misc/term-color')
| -rwxr-xr-x | misc/term-color | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/misc/term-color b/misc/term-color new file mode 100755 index 0000000..85bf44b --- /dev/null +++ b/misc/term-color @@ -0,0 +1,43 @@ +#! /usr/bin/env python +# Copyright (C) 2006 by Johannes Zellner, <johannes@zellner.org> +# modified by mac@calmar.ws to fit my output needs +# modified by crncosta@carloscosta.org to fit my output needs +# pyroscope.project@gmail.com 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") |
