For example, I have formed a long complicated command that will improve the world and lower an entropy in the Universe. But then (huh!) I see that I forgot to make a dir required. I want to store my command, run
mkdir and then restore my command.
Assume doing it in a raw tty.
Is there a way to do so?
On your command-line press Ctrl–u (it stores it in the kill-ring), issue the other one
mkdir for example, and then press Ctrl–y.
set -o vi command or
set -o emacs (typically one would store this in .bashrc for convenience). This enables a vi-style (or emacs type) line editing interface.
This provides you with a command line vi editor. You can search for previous commands, edit commands, etc.
Use ESC key to enter vi command mode, then
Use UP and DOWN keys, (or
k) to list found commands
Hit ESC key
Then edit the long command in a vi editor.