Scenario:
You are doing your daily Bash shell stuff. You want to run a previous command so you type:
history | grep foocommand
Then you get a list of all the foocommand
stuff you did for however long your history has kept track, in a list like so:
585 foocommand --baz --bleet
750 foocommand | grep quux
987 history grep | foocommand
You decide you want to run command 585, so you type
!585
Question: Just for curiosity, is there a way to take that final step out of the equation and still get the expected outcome? It would be nice if there were a way to say:
"grep through history and automatically run the first item on the list"
or
"grep through history and let me choose which item to run using the arrow keys"
Press ^r
(that's CTLR-r
), type foocommand
press Enter ;)
That will search history and show the latest matching entry
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With