When working in the terminal, I use the history a lot to repeat common commands, or to slightly edit previous commands. However, the default key bindings are not very efficient. You can scroll up and down the history using the arrow keys, but what if you want the last 'renice' command? You then have to search the history.
What I've done is made it so that the arrow keys will search the history for commands that match what you have typed so far. Read the rest of the article if you'd like to see what changes I've made...
Let's assume I've run the following commands:
% mv FileA FileBNow, let's say I want to change back to the etc directory. The fastest way to do this is type cd then hold the control key and hit "[", then hold the shift key and hit "P" to make it auto-complete to the last 'cd' command. However, this is a pain. Type the following into the terminal:
% cd /usr/local/etc
% ls -l
% cd ~
% ls -l
bindkey -k down history-search-forwardNow, I can just type cd (up-arrow key) to get the last 'cd' command. If you wish to just flip through the history, just use the arrow-keys before you type anything in. Repeatedly hitting the arrow keys will let you peruse through all matches in the history.
bindkey -k up history-search-backward
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020114182552310