Prepend the name of any command which does nothing important to what you have written, and run the resulting command line. This is along the lines of @goldilocks's answer, but more generic.
Examples would be true
, false
and echo
. Just move to the beginning of the command line and prepend whatever command you prefer to what you have already written.
$ true git commit -am 'FOO-123: fix issue with dorks around bars'
$
Since true
is essentially a no-op, the command is now in the history (regardless of which shell you are using, as long as it has a command history at all) and can be recalled normally whenever you are ready, but nothing else has happened. When you are ready, recall the command from the history, back up to the beginning of the command line and remove the no-op command before executing.
The only real downside of this is that you lose whatever the exit status was from the previous command ($?
in bash-speak). If you are doing more than a simple command invocation (chaining operations like ;
, &&
and ||
, pipes, redirection, ...) you may need to quote the command before passing it to the no-op command, so the shell doesn't do its magic on part of the command. Something like false && ( ... )
(with ...
being what you had before) might also work; since false
will return an unsuccessful result, the shell will never get to the remainder of the command line.
Another option, especially if you are running in a graphical environment, is to simply open another terminal window. In a CLI-only environment the same can be accomplished by starting screen
first thing when you log in -- then you can trivially detach the current session and start a new one.
push-line
, just pressESC-q
in emacs keybindings – Ulrich Dangel Mar 20 '13 at 13:38