Just a question to improve my bash
skills. I always do this:
$ history | grep some_long_command
...
...
123 some_long_command1.........
124 some_l
Instead of using the history
command, bind history-search-backward
/history-search-forward
to key shortcuts which can be remembered easily (I prefer PgUp/PgDown). To do that, put this into your .inputrc
file:
"": history-search-backward
"": history-search-forward
To get
, type Ctrl-V
in the shell, and replace the starting ^[
with \e
in whatever was output.
After this is set up, you can just 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
later in the history, you can cycle through until you reach it by typing some
and then hitting PgUp repeatedly, or you can type some
, hit PgUp, move the cursor to where the two commands start to differ, type a few characters and hit PgUp once more. This ability to quickly page through / differentiate between similar commands makes it in my opinion a much more comfortable tool than Ctrl-R
.