shithub: riscv

ref: 55c3138c640967ae82b21feb4c33acb9edcbc75b
dir: /rc/bin/"/

View raw version
#!/bin/rc

rfork en

PROMPT='[^ 	]*(%|;)[ 	]+'

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.