mirror of
https://github.com/imcarlost/pidcat-repl.git
synced 2026-08-08 23:17:43 -04:00
Only output in color when stdout is a TTY
This commit is contained in:
@@ -78,6 +78,8 @@ named_processes = map(lambda package: package if package.find(":") != len(packag
|
||||
|
||||
header_size = args.tag_width + 1 + 3 + 1 # space, level, space
|
||||
|
||||
stdout_isatty = sys.stdout.isatty()
|
||||
|
||||
width = -1
|
||||
try:
|
||||
# Get the current terminal width
|
||||
@@ -97,7 +99,7 @@ def termcolor(fg=None, bg=None):
|
||||
return '\033[%sm' % ';'.join(codes) if codes else ''
|
||||
|
||||
def colorize(message, fg=None, bg=None):
|
||||
return termcolor(fg, bg) + message + RESET
|
||||
return termcolor(fg, bg) + message + RESET if stdout_isatty else message
|
||||
|
||||
def indent_wrap(message):
|
||||
if width == -1:
|
||||
|
||||
Reference in New Issue
Block a user