Skip to content

Instantly share code, notes, and snippets.

@kangarie
Created November 10, 2024 20:46
Show Gist options
  • Save kangarie/54c1e1516bce8815aefb10e079b4b711 to your computer and use it in GitHub Desktop.
Save kangarie/54c1e1516bce8815aefb10e079b4b711 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
command = "ps axo user:30,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,comm"
l = subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8").split("\n")
minlen = sorted(set([30-len(item.split(" ")[0]) for item in l]))[0]
for line in l:
print(line[:30-minlen]+line[30:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment