Personally I prefer the Windows way of command history traversal (sorry!) where each command retains its place in the history and when you return to the last-executed command it's not necessarily last in the history.
Not sure if that makes sense so I will try to explain with examples.
Bash
Suppose I executed four commands (one
, two
, three
, four
). After this, the command history (from earliest to most recent) looks like:
one
two
three
four
Now if I press up three times, I will go back to four
, then three
, then two
as expected. If I press enter, I will execute command two
. Now the history looks like:
one
two
three
four
two
If I press ↑ I will see two
. If I press it again, I will see four
and so on.
Windows
Suppose I executed the same four commands (one
, two
, three
, four
). After this, the command history (from earliest to most recent) looks like:
one
two
three
four
Now if I press up three times, I will go back to four
, then three
, then two
as before. If I press enter, I will execute command two
. Now pressing ↑ again, it will still show two
. But the history still looks like:
one
two
three
four
What this means is that I have "jumped" back to an earlier point in the history. I can now press ↑ to see one
, or ↓ to see three
, etc.
Why this is useful
This is particularly useful when you have just run a series of commands and you want to run them again. It involves significantly less keystrokes to run the whole series again.
Is there a way to cause bash to behave the same way?