Displaying what `history` line is current in bash prompt
- by warren
What formatting character needs to be added to a bash prompt to indicate the most recent history item run (or the current command number if 1 could be added to the last history entry)?
My prompt string is this:
\[\033[33m\][\u@\[\033[1;31m\]\h]\]\033[0m {\W}\n\033[1;34m\]\w\]\033[0m >
Gives me the following display:
[user@host] {~}
~ >
User is in yellow, and the host is in red. The entry in brackets is the current directory, and the entry before the greater-than sign is the full pwd.
Can I append to the first line the current command number so I would have something like the following:
[user@host] {~} (nnn)
~ >
where (nnn) is the current (or just processed) command number, as shown when running history?