aboutsummaryrefslogtreecommitdiff
path: root/bin/psu
blob: 5f514f78002cb4fc606911f65c01683740a2659b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

flag=''
if [ "x$1" = "x-a" ]
then
	flag=-a
	shift
fi

case $# in
0)
	user=$USER
	;;
1)
	user=$1
	;;
*)
	echo 'usage: psu [-a] [user]' 1>&2
	exit 1
esac

9 ps $flag | grep "^$user " | awk '
	BEGIN { min = 1000000 };
	{ 
		line[0+nline++] = $0;
		n = length;
		sub(/ +/, "", $0);
		n -= length;
		if(n < min)
			min = n;
	}
	END{
		s = "";
		for(i=0; i<min-1; i++)
			s = s " ";
		for(i=0; i<nline; i++){
			sub(s, "", line[i])
			print line[i]
		}
	}
'