Bash Command (History) Number In PS1

bashcommand historyprompt

history lists previous commands and their number e.g.

$ history
286 clear

I want to be able to see the command number as I type a new command, instead of having to type history

Essentially:

[ username ubuntu ~ ] $ becomes

[ username ubuntu ~ ] 286 $

Does anyone know how to achieve this in .bashrc, .bash_profile, .profile etc..?

Best Answer

\! is the history number. Source.

Related Question