ps_f 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +7 -7
- data/bin/ps_f +15 -3
- metadata +3 -3
data/README
CHANGED
@@ -16,15 +16,15 @@ gem install ps_f
|
|
16
16
|
|
17
17
|
shell> ps_f
|
18
18
|
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
|
19
|
-
root 1 0.0 0.0 2512260 2160 ?? Ss 9:05AM 0:09.81
|
19
|
+
root 1 0.0 0.0 2512260 2160 ?? Ss 9:05AM 0:09.81 launchd
|
20
20
|
sugawara 260 0.0 0.1 2563928 13648 ?? Ss 9:05AM 0:01.49 \_ com.apple.dock.extra
|
21
|
-
sugawara 231 0.0 0.0 2511704 1756 ?? Ss 9:05AM 0:04.48 \_
|
22
|
-
sugawara 718 1.6 0.8 3793428 131332 ?? S 9:07AM 2:37.60 | \_
|
21
|
+
sugawara 231 0.0 0.0 2511704 1756 ?? Ss 9:05AM 0:04.48 \_ launchd
|
22
|
+
sugawara 718 1.6 0.8 3793428 131332 ?? S 9:07AM 2:37.60 | \_ iTerm -psn_0_208947
|
23
23
|
root 3453 0.0 0.0 2479984 2288 s001 Ss 9:50AM 0:00.02 | | \_ login -fp sugawara
|
24
24
|
sugawara 3454 0.0 0.0 2435492 2104 s001 S+ 9:50AM 0:00.04 | | | \_ -bash
|
25
25
|
root 10710 0.0 0.0 2490224 2328 s003 Ss 12:11PM 0:00.01 | | \_ login -fp sugawara
|
26
|
-
sugawara 672 0.3 1.4 1465496 231208 ?? S 9:07AM 7:19.22 | \_
|
27
|
-
sugawara 18426 2.9 0.3 908880 57228 ?? S 2:40PM 0:16.89 | | \_
|
28
|
-
sugawara 7838 0.0 0.3 908424 54156 ?? S 11:18AM 0:02.44 | | \_
|
29
|
-
sugawara 4054 0.0 0.4 915828 71916 ?? S 10:02AM 0:05.18 | | \_
|
26
|
+
sugawara 672 0.3 1.4 1465496 231208 ?? S 9:07AM 7:19.22 | \_ Google Chrome -psn_0_155686
|
27
|
+
sugawara 18426 2.9 0.3 908880 57228 ?? S 2:40PM 0:16.89 | | \_ Google Chrome Helper --type=rendere
|
28
|
+
sugawara 7838 0.0 0.3 908424 54156 ?? S 11:18AM 0:02.44 | | \_ Google Chrome Helper --type=rendere
|
29
|
+
sugawara 4054 0.0 0.4 915828 71916 ?? S 10:02AM 0:05.18 | | \_ Google Chrome Helper --type=rendere
|
30
30
|
...
|
data/bin/ps_f
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
wide = false
|
5
|
+
opt = OptionParser.new
|
6
|
+
opt.on('-w', '--wide') {|v| wide = v }
|
7
|
+
opt.parse!(ARGV)
|
8
|
+
|
2
9
|
out = `ps awxu -o ppid,command`
|
3
10
|
exit 1 unless $?.success?
|
4
11
|
|
@@ -28,7 +35,7 @@ end
|
|
28
35
|
|
29
36
|
roots = tree.select {|pid, ppid, command| ppid.zero? }
|
30
37
|
|
31
|
-
def asm(tree, roots, pre_prefix, cmd_list)
|
38
|
+
def asm(tree, roots, pre_prefix, cmd_list, basename_only)
|
32
39
|
h = {}
|
33
40
|
|
34
41
|
roots.each do |pid, ppid, command|
|
@@ -40,18 +47,23 @@ def asm(tree, roots, pre_prefix, cmd_list)
|
|
40
47
|
list.sort_by {|a, b| a[0] }.each_with_index do |pid_cmd, i|
|
41
48
|
pid, command = pid_cmd
|
42
49
|
|
50
|
+
if basename_only
|
51
|
+
head, tail = command.split('-', 2)
|
52
|
+
command = File.basename(head) + (tail ? '-' + tail : '')
|
53
|
+
end
|
54
|
+
|
43
55
|
cmd_list << [pid, pre_prefix + ' \_ ' + command]
|
44
56
|
|
45
57
|
children = tree.select {|child| pid == child[1] }
|
46
58
|
child_pre_prefix = pre_prefix + ((i < list.length - 1) ? ' | ' : ' ')
|
47
59
|
|
48
|
-
asm(tree, children, child_pre_prefix, cmd_list)
|
60
|
+
asm(tree, children, child_pre_prefix, cmd_list, basename_only)
|
49
61
|
end
|
50
62
|
end
|
51
63
|
end
|
52
64
|
|
53
65
|
cmd_list = []
|
54
|
-
asm(tree, roots, '', cmd_list)
|
66
|
+
asm(tree, roots, '', cmd_list, !wide)
|
55
67
|
|
56
68
|
tree_rows = cmd_list.map do |pid, command|
|
57
69
|
row = rows[pid]
|
metadata
CHANGED