Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
Created October 1, 2019 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavorv86/25b78efe34de4fd0a74c13eaab6589ac to your computer and use it in GitHub Desktop.
Save gustavorv86/25b78efe34de4fd0a74c13eaab6589ac to your computer and use it in GitHub Desktop.
Print Bash palette color in python
#!/usr/bin/env python3
def colors_16():
print("\n\n8/16 COLORS\n")
buff = ""
for i in range(30, 38):
buff += "\t\033[{}m {}".format(i, i)
print(buff)
buff = ""
for i in range(90, 98):
buff += "\t\033[{}m {}".format(i, i)
print(buff)
print("\033[0m")
def colors_256():
print("\n\n88/256 COLORS\n")
buff = ""
for i in range(0, 256):
buff += "\t\033[38;5;{}m {} ".format(i, i)
if (i+1) % 8 == 0:
buff += "\n"
print(buff)
print("\033[0m")
def main():
colors_16()
colors_256()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment