Every now and then I want to recycle a command sequence I recently used, after I adapted it.
Let's imagine, yesterday I executed
foo 42 bar with some strange arguments baz /my/most/beloved/folder
Now today I need to something similar like
foo -x 42 bar with some more strange arguments baz /my/most/hated/folder
I can use ctrlR and
foo to find yesterday's command (maybe multiple times, because I use
foo in different contexts), change it and execute it. No problem so far. But now I'd love to quickly jump to the following line in history without repeating the lengthy search again (in reality often more than ten commands).
fc command of
ksh comes close to what I want, but it is not interactive: If I issue a dozen
git commands I may need to react to one of them responding other than expected (or executing the following commands will cause a mess).
cmd shell of MS Windows has a (for me usually annoying) behaviour: After executing a command from history, the up arrow doesn't take me to the last command in history, but to the last executed command, so after executing the
foo line again, arrow up and then arrow down would take me to the
bar line. This exact behaviour would not help me, because it only work when executing an unmodified line. If I modify it, the »history pointer« is set to the end again. But it would be the perfect solution to have such a bookmark in history, set it at the
foo line and have a key combination to take me back there or even better to the following line, moving the bookmark.
I guess I'm not the only one with such a need, but I did not find any solution to it. Currently I solve it by printing the relevant part of history and use the mouse to paste the line I need next, but this is clumsy and I don't ilke to switch between keyboard and mouse. And please get away with history expansion; I typically need to interactively edit the line, including tab expansion.
Do you know any solution, preferably for