In Ubuntu 12.04 I use CTRL-R to enter a reverse history search. If the command I want is not found (after repeated CTRL-R), how do I immediately exit back to the (empty) command prompt with no historical command entered or executed on the command line?

  • 1
    I can not believe that I googled this and that it has been asked and answered already :D – Nikhil Jul 9 at 14:13

CtrlG this will abort the search


You can use:

  • The Emacs style keyboard quit command, Ctrl-G. Default key bindings in bash are purposefully Emacs-like.
  • The Vi style return to normal mode key bindings, Esc or Ctrl-[ (they're the same thing) .
  • Send a SIGKILL signal, Ctrl-C.

The first two have the least visible effect.

  • {Grin} You can prevent the display of "^C" if you add stty -ctlecho to your startup files (.bashrc,.profile,.zshrc, etc) Now ALL three methods have least visible effect. – lornix Jul 14 '12 at 17:39
  • for some reason Esc and Ctrl-C do not work on the Ubuntu systems I have tried (including my current 12.04). – MountainX Jul 15 '12 at 17:52
  • @lornix: I like to have visual feedback of Ctrl-C. Just imagine the psychological impact of pressing Ctrl-C before submitting a command like rm -rf / (extreme example), going away, then coming back to the terminal. There's practical joke potential in this, of course. – Alexios Oct 8 '12 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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