2

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?

  • it looks like tcsh is reading a single control character when i-search-back is active. not sure why. – Gregory Nisbet May 20 '16 at 2:05
1

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

|improve this answer|||||
1

Reading the 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".

|improve this answer|||||

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.