serhii.net

In the middle of the desert you can say anything you want

19 Apr 2023

Re-running commands with fc

> history

10640  echo command 1
10641  echo command 2
10642  echo command 3

Usually I’d !10640 !10642 to run 1 and 3, but there’s fc!1

fc

fc -l to list instead of invoke.

fc first last, where the latter ones can be e.g:

  • 12 for command 12
  • -12 for command executed 12 commands ago

Then:

> fc -l 10639 
10639  h apt
10640  echo command 1
10641  echo command 2
10642  echo command 3
10643  history

> fc -l 10639 10642
10639  h apt
10640  echo command 1
10641  echo command 2
10642  echo command 3

> fc 10639 10642
% opens vim with these commands, edit then they get run on close.
Nel mezzo del deserto posso dire tutto quello che voglio.