Yes. If you use
fc
with no parameters, it will bring up the last command you entered, in a temporary file, in a text editor. Allowing you to edit the command you previously entered.
After changing the command and saving and quitting the editor, the edited command will then be ran.
This is especially useful if you entered a long command and wanted to run it again, but with slightly different parameters.
You can also use
-s
flag to searh for a recent command.
E.g.
Would search your bash history for the most recent
gcc
command you entered and would open it in a text editor, so you could edit it and re-run it.
If memory serves, the editor used by
fc
is defined in the environment variable
$FSEDIT
. If
$FSEDIT
doesn’t exist/is empty, it falls back to use whatever is set in
$EDITOR
. If
$EDITOR
is empty, it falls back to use
vi
(which nowadays is actually vim-minimal running in "compatible" mode, which emulates classic
vi
).
More and more distro’s currently use
nano
as the default terminal based editor. But many still have vi/vim-minimal installed too.
I’m guessing your distro uses
nano
as its default editor. So that is why your last command was opened in a file in
nano
.