Tcsh
tcsh: i-search-back 字元故障
正如在其他一些答案中所見,我將其添加到我的 .cshrc 以使 CTRL-R 的行為類似於 bash:
bindkey "^r" i-search-back
它一般工作正常。我的問題是,當 CTRL-R 後跟左箭頭或右箭頭(編輯行)時,它會在游標位置添加“[C”或“[D”,然後我必須手動刪除. 知道為什麼,以及如何避免它嗎?
先使用 Esc 鍵退出搜尋,然後使用左右鍵進行編輯。
閱讀手冊頁,這是行不通的:
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 會丟棄它,將可列印字元作為“正常輸入”的一部分。