hishamhm / htop

htop is an interactive text-mode process viewer for Unix systems. It aims to be a better 'top'.
GNU General Public License v2.0
5.83k stars 581 forks source link

Add option to collapse trees deeper than specified level #1002

Closed misebox closed 4 years ago

misebox commented 4 years ago

This is just a proposal with code. Please feel free to close.

The option collapses trees that are deeper than specified level.

The option character is '-l' (small L) from Level. It's collapseLevel in code. Checking whether a process has any child or not is because to set better value to "Process.showChildren". It improves +/- signs before process name. The collapseLevel will be cleared when user expands or collapses any tree.

I don't know this is reasonable approach or not, but I think it's practical one. Of course, htop is an important tool and should be implemented carefully. I hope it will be useful stuff as one of the experiments.

Thank you.

Examples:

htop -t -l 0
htop -t -l 1

↑ Some of signs are "+" those have any child processes, other signs are "-".



htop -t -l 2
htop -t   # without -l option