These tips can be used with the OS X terminal, iTerm, and most Linux shells. I have also verified the history works with the Windows “DOS Prompt”. It’s nice when things work out in a consistent cross-platform way. 😉
The history feature is useful when a programmer wishes to perform similar commands over again. In the past the process used to be more complex. Now it’s as simple as using the up arrow key. The down arrow key works to go the other direction. Many of those just getting familiar with the various terminal or shell commands will at first find this feature somewhat dubious. Here is a situation where the history feature really shines. Picture writing a program for a couple of hours and saving it. When run it has a syntax error. By using the history the programmer can save keystrokes to get back to where they were before. A second example would be a long command with a mistake on the line. Not realising the mistake the programmer presses the <Enter> key. Naturally the program doesn’t do what was expected. The programmer can use the history to recall the previous command and figure out where the problem was, then correct it.