On almost all modern command-line environments I've used, you can hit up arrow to go back a few commands in your history and re-run an earlier command. But on some command-line environments I've used, at the next command prompt after doing that, you can also hit down-arrow to browse your history from the place where the previous command appeared in the history.
For example, suppose you do this:
$ vi mysource.c
$ make
$ make test
Then suppose your test fails and you want to go back through these steps again, so you hit up-arrow 3 times to get back to vi mysource.c
, and hit return to run that. Then, at the next prompt after that, I want to be able to hit down-arrow once to get to make
. And at the next prompt after that, I want to hit down-arrow once to get to make test
.
I don't know if it comes down to Mac OS X's default bash
settings, or default Terminal.app settings, or what, but this "hit the down arrow at a new prompt to browse history down from the last place you used the history" functionality is not enabled by default.
I browsed the bash(1)
man page and found:
forward-search-history (C-s)
...but ^S
didn't seem to do anything. Not sure if it was being swallowed up by Terminal as an old-school XOFF
or something (although it didn't seem to pause terminal output).
A few other notes:
- I'm on Mac OS X Snow Leopard 10.6.6.
- I'm already aware of lots of other fun ways to work with the shell history, it's just this one particular thing that I'm trying to get working right now.
- Although any pointers in the right direction would be helpful, solutions known to work on 10.6.x's
bash
in Terminal.app would be super extra helpful.