How do I abort fc without executing the command?
From vi you can type :cq
to exit without saving and with a non-zero return code. In this case the command will not be repeated.
Alternatively, you can usually suspend the editor with ctrl-z which gets you back to the shell without redoing the command. You still have to fg
to restart the editor, but the tmp file will no longer be around, so you can safely quit the editor. Or you can kill -9 %
this suspended editor.
I agree, it could be easier. Of course, you can always edit lines within bash using vi or emacs commands.
Perhaps, an easier way to remember is to delete the command (dd should do) and quit (ZZ
or any other way to quit with saving should do). IMHO, :cq
is quite arcane.