Last active
November 29, 2023 06:03
-
-
Save limingjie/036523669f428105ca81 to your computer and use it in GitHub Desktop.
check if terminal supports 256 colors
This file contains hidden or 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
#!/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 | |
# Original source: https://github.com/incitat/eran-dotfiles/blob/master/bin/terminalcolors.py | |
import sys | |
import os | |
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") | |
# 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 < 231: | |
for z in range(0,6): | |
out(y) | |
y += 1 | |
echo("\n") | |
echo("\n") | |
for n in range(232, 256): | |
out(n) | |
if n == 237 or n == 243 or n == 249: | |
echo("\n") | |
echo("\n") | |
os.system("tput setaf 7") | |
os.system("tput setab 0") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment