At least on linux there a the tools tac
(which prints lines in reverse order) and nl
(which numbers lines).
So this should do the trick although without leading -
:
extended_history () {
history "$@" | tac | nl | tac
}
If you really want the -
extended_history () {
history "$@" | tac | nl | tac | sed 's/^\( *\)\([0-9]\)/\1-\2/'
}