Skip to content

Commit

Permalink
Adjust PID column width for longer PIDs
Browse files Browse the repository at this point in the history
Closes #15. Thanks to @rookielxy .
  • Loading branch information
peci1 authored Aug 31, 2021
1 parent 7b53fba commit bbec8f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nvidia-htop.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ def colorize(_lines):
time[idx] = parts[4] if "-" not in parts[4] else parts[4].split("-")[0] + " days"
command[idx] = parts[5]

format = ("| %3s %5s %8s %8s %5s %5s %9s %-" + str(command_length) + "." + str(command_length) + "s |")
max_pid_length = max([len(str(x)) for x in pid])
if max_pid_length >= 6:
command_length -= (max_pid_length - 6)

format = ("| %3s %" + str(max_pid_length) + "s %8s %8s %5s %5s %9s %-" + str(command_length) + "." + str(command_length) + "s |")

print(format % (
"GPU", "PID", "USER", "GPU MEM", "%CPU", "%MEM", "TIME", "COMMAND"
Expand Down

0 comments on commit bbec8f8

Please sign in to comment.