Bash's ctrl-o timesaver
23 December 2024
I have long been an enthusiastic user of the reverse search (ctrl-r) feature in the bash shell. To recap, if you have a history of typed commands that looks like this:
... make build make test make deploy ...
...then instead of typing out make build in full the next time you can type ctrl-r b u i which shows a preview like so:
(reverse-i-search)`bui': make build
Now you can press enter and the command runs.
Now suppose you want to run the those three historical make commands, one at a time, in sequence? Past foolish me would have done something like ctrl-r b u i enter ctrl-r t e s enter ctrl-r d e p enter.
The other day I learnt that you can do: ctrl-r b u i ctrl-o ctrl-o enter. Each time you press ctrl-o it runs the command and then replaces the search prompt with the command that followed it.
So this is a very fast way to go back and re-run a sequence of commands. Now I just need to make my muscle memory use it...
Tech Tidbits Blog by Thomas Karpiniec
Posts RSS, Atom