Skip to content

Instantly share code, notes, and snippets.

@yyolk
Created January 31, 2024 00:29
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 yyolk/018b82106f38bc59fbac92719f7e4838 to your computer and use it in GitHub Desktop.
Save yyolk/018b82106f38bc59fbac92719f7e4838 to your computer and use it in GitHub Desktop.
basic python ansi colors to vendor into your project without needing to pip install
class AnsiColors:
fg_black = "\u001b[30m"
fg_red = "\u001b[31m"
fg_green = "\u001b[32m"
fg_yellow = "\u001b[33m"
fg_blue = "\u001b[34m"
fg_magenta = "\u001b[35m"
fg_cyan = "\u001b[36m"
fg_white = "\u001b[37m"
bg_black = "\u001b[40m"
bg_red = "\u001b[41m"
bg_green = "\u001b[42m"
bg_yellow = "\u001b[43m"
bg_blue = "\u001b[44m"
bg_magenta = "\u001b[45m"
bg_cyan = "\u001b[46m"
bg_white = "\u001b[47m"
reset = "\u001b[0m"
bold = "\u001b[1m"
underline = "\u001b[4m"
reverse = "\u001b[7m"
def bg(self, r, g, b):
return f"\u001b[48;2;{r};{g};{b}m"
def fg(self, r, g, b):
return f"\u001b[38;2;{r};{g};{b}m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment