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
""", re.X)
terminal_size = shutil.get_terminal_size()
TERM_WIDTH = terminal_size.columns
TERM_WIDTH = os.getenv('TERM_WIDTH')
try:
TERM_WIDTH = int(TERM_WIDTH)
except:
terminal_size = shutil.get_terminal_size()
TERM_WIDTH = terminal_size.columns
def colorize(message):