4

As seen in a few other answers, I added this to my .cshrc to make CTRL-R behave similar to bash:

bindkey "^r" i-search-back

It works fine in general. My problem is that when doing CTRL-R followed by a left or right arrow (to edit the line), it will add a "[C" or "[D" at the position of the cursor, which I then have to delete manually. Any idea why, and how I can avoid it?

1
  • it looks like tcsh is reading a single control character when i-search-back is active. not sure why. Commented May 20, 2016 at 2:05

2 Answers 2

3

Reading the tcsh manual page, that will not work:

   i-search-back (not bound)
           Searches  backward  like  history-search-backward,  copies  the
           first match into the input buffer with the cursor positioned at
           the end of the pattern, and prompts with `bck: ' and the  first
           match.   Additional  characters  may  be  typed  to  extend the
           search, i-search-back may be typed to continue  searching  with
           the  same  pattern,  wrapping around the history list if neces‐
           sary, (i-search-back must be bound to a  single  character  for
           this to work) or one of the following special characters may be
           typed:

               ^W      Appends the rest of the word under  the  cursor  to
                       the search pattern.
               delete (or any character bound to backward-delete-char)
                       Undoes  the  effect of the last character typed and
                       deletes a character  from  the  search  pattern  if
                       appropriate.
               ^G      If  the  previous search was successful, aborts the
                       entire search.  If not, goes back to the last  suc‐
                       cessful search.
               escape  Ends  the  search,  leaving the current line in the
                       input buffer.
           
           Any other character not bound to self-insert-command terminates
           the  search,  leaving the current line in the input buffer, and
           is then interpreted as normal input.  In particular, a carriage
           return  causes  the  current  line  to be executed.  Emacs mode
           only.  See also i-search-fwd and history-search-backward.

The manual page tells you that the only special characters that tcsh is prepared to handle are the four listed, and that anything else is interpreted as

  • Additional characters may be typed to extend the search, and
  • "Any other character not bound to self-insert-command terminates the search, leaving the current line in the input buffer, and is then interpreted as normal input.

Since the escape character (which is part of the left/right arrow) is nonprinting, tcsh discards that, leaving the printable characters as part of the "normal input".

2

Use Esc key first to exit the search, then use right or left keys for editing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .