Instead of using the history command, bind history-search-backward / history-search-forward to key shortcuts that can be easily remembered (I prefer PgUp / PgDown). To do this, put this in your .inputrc file:
"<key code>": history-search-backward "<key code>": history-search-forward
To get <key code> , enter Ctrl-V <key> in the shell and replace the initial ^[ with \e with everything that was printed.
After that, you can simply type some and press PgUp to get some_long_command . If you need some_long_command with_some_arg , but there is a similar command some_long_command with_some_other_arg in the history, you can scroll it until you reach it by typing some and then pressing PgUp several times, or you can type some , press PgUp, move the cursor there , where the two commands begin to differ, enter a few characters and press PgUp again. This ability to quickly scroll through / distinguish between similar commands makes it, in my opinion, a much more convenient tool than Ctrl-R .
Tgr Feb 20 '13 at 15:17 2013-02-20 15:17
source share