tcsh:i-search-back 字符故障

tcsh:i-search-back 字符故障

正如在其他一些答案中看到的,我将其添加到我的 .cshrc 中以使 CTRL-R 的行为类似于 bash:

bindkey "^r" i-search-back

总体来说效果很好。我的问题是,当执行 CTRL-R 后跟向左或向右箭头(编辑行)时,它将在光标位置添加“[C”或“[D”,然后我必须手动删除它。知道为什么吗?我怎样才能避免它?

答案1

正在阅读tcsh 手册页, 这是行不通的:

   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.

手册页告诉您 tcsh 准备处理的唯一特殊字符是列出的四个字符,其他任何字符都被解释为

  • 可以输入其他字符来扩展搜索,
  • “任何其他未绑定到 self-insert-command 的字符都会终止搜索,将当前行保留在输入缓冲区中,然后被解释为正常输入。

由于转义字符(左/右箭头的一部分)是非打印字符,因此 tcsh 会丢弃该字符,将可打印字符保留为“正常输入”的一部分。

答案2

先使用Esc 键退出搜索,然后使用左右键进行编辑。

相关内容