From b0eb414d7695be6863fea8c8567590450532a661 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Fri, 5 Jul 2024 22:00:13 +1000 Subject: [PATCH] ports: Colorize --- ports | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports b/ports index 5a87b57..44d7233 100755 --- a/ports +++ b/ports @@ -110,5 +110,9 @@ for pid in pids: if state == "D" and "-v" in sys.argv: print(pid, "DiskSleep", title, "ppid", ppid) except FileNotFoundError: pass # Process must have terminated while we were searching -print("Procs", len(pids), f"({status['D']} D, {status['R']} R)") +if status["D"] > 10 or status["R"] > 30: color = "\x1b[1;31m" +elif status["D"]: color = "\x1b[1;33m" +elif status["R"] > 10: color = "\x1b[1m" +else: color = "\x1b[1;32m" +print(f"Procs {color}{len(pids)} ({status['D']} D, {status['R']} R)\x1b[0m") sys.exit(error)