Postpone current command and run another first in zsh

Sometimes I am halfway through writing a command and realize I need to run something else first. Just now I was writing a git commit command and realized I should edit the TODO file first. So usually I either ^U to clear the command and type vim TODO before writing the commit command again or maybe open a new terminal or maybe even ^A to go to the start of the line and add vim TODO; to the beginning.

But zsh has a buffer stack which comes in useful here. The default key binding for push-line is ESC q. This pushes the current buffer (command in progress) onto the stack and clears the buffer, then pops from the stack next time the prompt is reached. So halfway through typing a commit command I do ESC q, type vim TODO, make whatever changes and exit and I'm back at a commandline with my half-typed commit command restored.

No comments:

Post a Comment