From 3ccc17fa2494671ec96fd78b3760b7725526f181 Mon Sep 17 00:00:00 2001 From: JustinOros Date: Mon, 4 Aug 2025 12:18:03 -0700 Subject: [PATCH] Fixed line number bug. --- topless.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/topless.py b/topless.py index 29aeb31..d3be70c 100644 --- a/topless.py +++ b/topless.py @@ -18,9 +18,9 @@ CONFIG_PATH = os.path.expanduser('~/.topless') DEFAULT_CONFIG = { 'text_color': 'black', - 'bar_color': 'green', + 'bar_color': 'gray', 'low_value': 0, - 'low_color': 'green', + 'low_color': 'gray', 'medium_value': 25, 'medium_color': 'yellow', 'medium_high_value': 50, @@ -153,13 +153,16 @@ def print_processes(limit, sort_key='cpu', reverse=True, show_quit_hint=True, us print(f"{pad}{BG_GRAY}{BLACK_TEXT}{header}\033[0m") width = len(str(limit)) + line_number_fmt = f"{{:0{width}d}}" + for i, proc in enumerate(top_processes, start=1): cpu = proc['cpu'] mem = proc['mem'] name = proc['name'] user = proc['user'] if show_line_numbers: - line = colorize(cpu, mem, name, user, config, use_color, line_number=i, width=width) + formatted_line_number = line_number_fmt.format(i) + line = colorize(cpu, mem, name, user, config, use_color, line_number=formatted_line_number, width=width) else: line = colorize(cpu, mem, name, user, config, use_color) print(f"{pad}{line}")