aboutsummaryrefslogtreecommitdiff
path: root/bin/"
blob: c1571d776e948509d08b54b409e899b10c1b1da4 (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
#!/usr/local/plan9/bin/rc

fn text {
	if(~ $winid [0-9]*)
		9p read acme/$winid/body
	if not if(~ $text9term unix!*)
		dial -e $text9term </dev/null
	if not
		status=''
}

PROMPT='[^ 	]*[%;$#][ 	]+'

fn cmds {
	text | 9 grep '^'$PROMPT'[^"]' | sed 's/^/	/'
}

switch($#*) {
case 0
	cmds | tail -1
case *
	cmds | 9 grep '^	'$PROMPT^$"* | {echo; cat} |
		pr -t -n | sort -nr | sort -u +1 | sort -n |
		9 sed 's/^ *[0-9]+	//' | grep .
}

# the silly {echo; cat} gets around pr printing "empty file" when
# presented with no input.