#!/usr/bin/env python import os, sys, argparse #NOTE: This script uses pygments for X256->RGB conversion since pygments is #readily available. If you do not like pygments (e.g. because it is large), #you could patch in something like https://github.com/magarcia/python-x256 #(but don't forget to send me a pull request ;) from pygments.formatters import terminal256 from PIL import Image, PngImagePlugin try: import re2 as re except: import re formatter = terminal256.Terminal256Formatter() def parse_escape_sequence(seq): codes = list(map(int, seq.lstrip('\x1b[').rstrip('m').split(';'))) fg, bg = None, None i = 0 while i