ptree: also show the argv of each command - plstree - ps and ls displayed as a tree HTML git clone git://bitreich.org/plstree git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/plstree DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit e3d30e6a69c7376cacf94f5cadc26d9a5655b5b3 DIR parent 022d132a4fddf73790e485de031f4da9d8ac6c81 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Sat, 9 Jun 2018 22:37:47 +0200 ptree: also show the argv of each command This is to avoid the need to constantly run "ps -ax | less -S" after "ptree | less", so only "ptree | less -S" is enough. Diffstat: M ptree | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- DIR diff --git a/ptree b/ptree @@ -33,7 +33,8 @@ BEGIN { printf("%s", entries[i":info"]); for (j = 1; entries[i":"j] != ""; j++) printf("%s", entries[i":"j]); - printf("%s\n", entries[i":comm"]); + printf("%-" 30 - j * 3 "s", entries[i":comm"]); + print(entries[i":args"]); } } @@ -46,7 +47,7 @@ BEGIN { function list(entries) { - opt = "-o ppid,user,tty,pid,stat,comm" + opt = "-o ppid,user,tty,pid,stat,comm,args" cmd = "exec ps -ax " opt " 2>/dev/null"; if (!(cmd | getline)) { cmd = "exec ps " opt @@ -60,9 +61,12 @@ function list(entries) entries[ppid"cpid"] = entries[ppid"cpid"] "," pid; sub(" *[^ ]+", ""); sub(" *[^ ]+ + *[^ ]+ + *[^ ]+ + *[^ ]+ +", "&\t"); + sub("[^\t]+ [^ ]+ +", "&\t"); split($0, info, "\t"); + sub(" *$" , "", info[2]); entries[pid"info"] = info[1]; entries[pid"comm"] = info[2]; + entries[pid"args"] = info[3]; } close(cmd); @@ -90,6 +94,7 @@ function fill(entries, pid, lvl) entries[NUM":"j] = LINE; entries[NUM":"lvl] = NODE; entries[NUM":comm"] = entries[pid"comm"]; + entries[NUM":args"] = entries[pid"args"]; entries[NUM":info"] = entries[pid"info"]; NUM++; while (sub("[^,]*,", "", entries[pid"cpid"])) {