#!/usr/lib/plan9/bin/rc

. 9.rc

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

fn cmds {
	wintext | sed -n 's/^'$PROMPT'([^"])/	\1/p'
}

switch($#*) {
case 0
	cmds | tail -1
case *
	cmds | grep -n '^	'^$"* | tail -r |
		sort -u +1 | sort -n |
		sed 's/^[0-9]+: //'
}
