I just learned about the
fc builtin to bash. I want to use it to edit and execute the previous two commands, including the most recent command.
I can edit-and-execute two commands up to but not including the most recent command with
fc -2 0. This is what I want, except offset by one to include the most recent command.
One workable but annoying solution is to examine the output of
fc -l), find the absolute command numbers, and give the command range in absolute terms. For example, if
fc -l -2 outputs the following:
502 echo hello 503 echo goodbye
…then I could say
fc 502 503. This is what I want, except that I don't want the extra step of examining history output. (I know, I'm picky.)
Is there any way to do this that doesn't involve (1) manual examination of the history or (2) a throwaway command to bump the commands of interest out of the most recent spot?
GNU bash version 3.2.57 on macOS, for what it's worth.