Allow setting TERM_WIDTH via env var

This commit is contained in:
Huy Ngo 2024-08-15 18:02:30 +07:00
parent b7dab5926e
commit 968864ae1f

View file

@ -35,8 +35,12 @@ STYLE_TAG_PATTERN = re.compile(r"""
> # literal > # literal
""", re.X) """, re.X)
terminal_size = shutil.get_terminal_size() TERM_WIDTH = os.getenv('TERM_WIDTH')
TERM_WIDTH = terminal_size.columns try:
TERM_WIDTH = int(TERM_WIDTH)
except:
terminal_size = shutil.get_terminal_size()
TERM_WIDTH = terminal_size.columns
def colorize(message): def colorize(message):