This is not your terminal, this is your shell.
The name for the shell mechanism that you are looking for is a kill buffer. People forget that shell command line editors have these. ZLE in the Z shell has them, as have GNU Readline in the Bourne Again shell, libedit in the (FreeBSD) Almquist shell, the Korn shell's line editor, and the TENEX C shell's line editor.
In all of these shells in emacs
mode, simply go to the end of the line to be saved, kill it to the head kill buffer with ⎈ Control+U, type and run the intermediate command, and then yank the kill buffer contents with ⎈ Control+Y. Ensure that you do not do anything with the kill buffer when entering the intermediate command.
In the Z shell in vi
mode, you have the vi
prefix sequences for specifying a named vi
-style buffer to kill the line into. You can use one of the other buffers instead of the default buffer. Simply use something like " a d d (in vicmd
mode) to delete the whole line into buffer "a", type and run the intermediate command, and then put that buffer's contents with " a p.
In their vi
modes, the Korn shell, GNU Readline in the Bourne Again shell, and libedit in the (FreeBSD) Almquist shell do not have named vi
-style buffers, only the one cut buffer. d d to delete the line into that buffer, followed by putting the buffer contents with p, will work. But it uses the same vi
-style buffer that killing and yanking will while entering the intermediate command.
#
in front of the command?