plan9fox/rc/bin/"

23 lines
374 B
Text
Raw Permalink Normal View History

2011-11-21 16:39:34 +00:00
#!/bin/rc
rfork en
2013-11-08 20:19:32 +00:00
PROMPT='[^ ]*(%|;)[ ]+'
2011-11-21 16:39:34 +00:00
fn cmds {
grep '^'$PROMPT'[^"]' /dev/text | sed 's/^/ /'
}
switch($#*) {
case 0
cmds | tail -1
case *
cmds | grep '^ '$PROMPT^$"* | {echo; cat} |
pr -t -n | sort -nr | sort -u +1 | sort -n |
sed 's/^ *[0-9]+ //' | grep .
}
# the silly {echo; cat} gets around pr printing "empty file" when
# presented with no input.