Skip to content

Instantly share code, notes, and snippets.

@joaoreboucas1
Created October 1, 2023 15:05
Show Gist options
  • Save joaoreboucas1/66c30eb32de488c3d10972fd7eb41617 to your computer and use it in GitHub Desktop.
Save joaoreboucas1/66c30eb32de488c3d10972fd7eb41617 to your computer and use it in GitHub Desktop.
Rainbow Hello! Prints different colored "Hello"s in the terminal
class ansi:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
PINK = '\x1b[38;5;207m'
PURPLE = '\x1b[38;5;127m'
def colors256(ID):
# https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#256-colors
return f'\x1b[38;5;{ID}m'
def print_ansi(message, ansi_char, **kwargs):
print(ansi_char + message + ansi.ENDC, **kwargs)
for i in range(256):
print_ansi('Hello', ansi.colors256(i), end=' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment