blob: c1571d776e948509d08b54b409e899b10c1b1da4 [file] [log] [blame]
rsc2b85f702005-01-11 20:58:13 +00001#!/usr/local/plan9/bin/rc
rsc47e0a2a2004-10-17 04:02:55 +00002
3fn text {
4 if(~ $winid [0-9]*)
5 9p read acme/$winid/body
6 if not if(~ $text9term unix!*)
7 dial -e $text9term </dev/null
8 if not
9 status=''
10}
11
12PROMPT='[^ ]*[%;$#][ ]+'
13
14fn cmds {
rsc2b85f702005-01-11 20:58:13 +000015 text | 9 grep '^'$PROMPT'[^"]' | sed 's/^/ /'
rsc47e0a2a2004-10-17 04:02:55 +000016}
17
18switch($#*) {
19case 0
20 cmds | tail -1
21case *
rsc2b85f702005-01-11 20:58:13 +000022 cmds | 9 grep '^ '$PROMPT^$"* | {echo; cat} |
rsc47e0a2a2004-10-17 04:02:55 +000023 pr -t -n | sort -nr | sort -u +1 | sort -n |
rsc2b85f702005-01-11 20:58:13 +000024 9 sed 's/^ *[0-9]+ //' | grep .
rsc47e0a2a2004-10-17 04:02:55 +000025}
26
27# the silly {echo; cat} gets around pr printing "empty file" when
28# presented with no input.
29