Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 13 down vote accepted

CtrlG this will abort the search

share|improve this answer

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.

share|improve this answer
    
{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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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