Running a subshell from the middle of the current command

I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.

Remember a half-typed command while I check something


There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.

(I didn't try to open a subshell after pressing EscQ yet.)

See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"


My solution to this is decidedly low-tech and clunky, but relies on key-sequences you're probably already familiar with: Hit Ctrl+A, then #, then ENTER.

This has the effect of inserting a # at the start of the line, thus making it a comment, then executing it, thereby pushing it into the command history. You may then enter your auxiliary command, then scroll up through the command history to the commented command, remove the # and complete the command as needed.