history | cat -n
would do it.
But don't forget that if you remove lines from the history you will not remove the number (because the historyfile of fish doesn't save them).
For example: When you remove the line cd Downloads
the 2nd ls
will become 400
.
zsh
on the other hand saves the numbers in ~/.zsh_history
file so here the 2nd ls
will stay 401
When using fish
you might be interested history --show-time
. It won't show the number, but it will show the time when every command was executed.
Edit: To answer your comment: history | cat -n | grep 315
But more useful: history | cat -n | less
followed by /, 3, 1, 5 and Enter.
That way you can easily see the commands right before and right after that specific command by using the up/down keys.
(I added the comment-answer to the original answer because key-formatting fails in comments)