2

In Bash, I often encounter below situation when doing reverse-i-search (using emacs keybinding in Bash):
(reverse-i-search:ccc) aaa bbb |ccc ddd
I am in the middle of reverse-i-search for 'ccc', and the cursor correctly stopped at matching string.

Now I want to start from here, and add some additional characters before ccc, e.g. making it eee ccc.
However, I cannot press Enter, otherwise the command is directly executed;
I can neither directly enter the characters I want to add, otherwise the search string is changed;
I cannot press Esc, otherwise bash will quit the search but also move the cursor.

So, how should I tell bash to quit the search but leave the cursor in place?

  • Do the Left and Right arrows do what you're looking for? – egmont Sep 19 '15 at 10:20
  • I don't understand what's wrong with 'Esc'. Can you elaborate? Or maybe this has been improved since you asked? Is the question still valid? – Kamil Maciorowski Sep 17 '17 at 20:14
  • @KamilMaciorowski It seems Esc now works. Possibly due to recent improvement. Thank you for bring this up. – modeller Sep 18 '17 at 4:38
  • @egmont This works as well. A bit late to reply to this. But thanks for bringing it up. – modeller Sep 18 '17 at 4:39
0

It seems there are several ways to do this now. Some or all of them didn't work at the time the question was asked.

  1. Esc

  2. Shift + Enter

  3. Also arrow keys (left, right) move cursor from desired position by one character.

$ bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

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.