I am looking for a way to delete the currently entered commandline without wasting seconds on the "Backspace"-key.

For example I scrolled the bash history and have a long commandline that would execute when I pressed ENTER:

~$ aptitude search openssl | grep dev

But now I decide that I do not want to execute this command. Can I get an empty prompt fast without deleting the whole line with Backspace? On the Windows "cmd" you can just press ESCAPE and it is gone. This behavior would be what I want.

The question may seem trivial but this is bothering me for a long time now... :-)

Regards

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

Pressing Ctrl+u will empty the current line.

link|improve this answer
Thanks, that did it. Ctrl-u deletes all characters before the cursor position. – vobject Sep 28 '10 at 10:38
+1: That's been driving me nuts :) – Mike Fitzpatrick Sep 28 '10 at 10:43
@vobject: If your cursor is within the line, Ctrl-u then Ctrl-k (or vice-versa) will get it all. – Dennis Williamson Sep 28 '10 at 16:55
feedback

Press Ctrl+C to cancel the command you're entering and go back to a bare prompt.

This is a common key in unix text mode applications:

  • in non-interactive programs, Ctrl+C usually stops the program altogether and goes back to a shell prompt;
  • in interactive programs that execute one command at a time (such as shells), Ctrl+C usually returns to the main command prompt.
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.