Created
January 4, 2017 09:45
-
-
Save jbbarth/b00e1fdfde08827e1df3e3057665ff32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
puts "#{"PID".ljust(7)} PROCESS" | |
lines = %x(ps auxfwww|grep " simplefl[o]w ").lines.map do |line| | |
stats, command = line.split("|", 2) | |
tokens = stats.split | |
{ pid: tokens[1], command: command } | |
end | |
exit if lines == [] | |
while lines.all?{|l| l[:command] && l[:command].match(/^(\|| )/) } | |
lines = lines.inject([]) do |memo, line| | |
memo << { pid: line[:pid], command: line[:command].sub(/^./, "") } | |
memo | |
end | |
end | |
lines.each do |line| | |
puts "#{line[:pid].ljust(7)} #{line[:command].sub(/^\|/, " ")}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment