bash中的control-r reverse-i-search:如何“重置"搜索框?在Cygwin中进行搜索? [英] Control-r reverse-i-search in bash: how do you "reset" the search in Cygwin?

查看:115
本文介绍了bash中的control-r reverse-i-search:如何“重置"搜索框?在Cygwin中进行搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:如何告诉 Ctrl + r 反向搜索重置自身"并从底部开始搜索你的历史每次?

Question: How do you tell Ctrl+r reverse-i-search to "reset itself" and start searching from the bottom of your history every time?

背景:在Bash中使用反向搜索时,一旦完成了对历史记录的搜索,我总是会卡住,并且找不到更多的匹配项.有时我打 Esc 并第二次重新调用 Ctrl + r ,期望它会从我的历史记录底部开始全新的搜索.但是,指针"似乎仍然是我历史上遗留的先前位置.

Background: When using reverse-i-search in Bash, I always get stuck once it is finished searching up through the history and it cannot find any more matches. Sometimes I hit Esc and re-invoke Ctrl+r a second time, expecting it to start a fresh new search from the bottom of my history. However the "pointer" still seems to be at the previous place it left off in my history.

问题是,我通常不希望出现这种情况.如果我按下 Esc ,然后重新调用 Ctrl + r ,我想表明它应该从底部重新开始并逐步恢复.

The problem is, I usually do not want this behavior. If I hit Esc, and then re-invoke Ctrl+r, I would like that to indicate it should re-start from the bottom again and work its way back up.

更新:我想我应该提到我在Windows上使用Cygwin,因为到目前为止提到的解决方案都没有.

Update: I guess I should have mentioned I am using Cygwin on Windows, as none of the so-far mentioned solutions work.

更新:该问题被标记为潜在重复问题.由于以下原因,此问题不是重复的问题:

Update: This question was marked as a potential duplicate question. This question is not a duplicate for the following reasons:

  • 替代问题与Cygwin无关.
  • 替代问题不涉及如何将搜索重置到其初始状态(相反,它仅涉及搜索中的后退和前进).
  • The alternate question does not deal with Cygwin.
  • The alternate question does not deal with how to reset the search to its initial state (instead it deals with simply going backward in search as well as forward).

推荐答案

在打Escape时,我从未尝试将其设置为默认值,但bash使用readline作为输入,默认情况下接受Emacs样式的键绑定,因此您可以使用M->到底部(通常是通过组合Meta/Alt和>或在Escape键后面加上>).

I never tried making this the default when hitting Escape, but bash uses readline for input, which accepts Emacs-style keybindings by default, so you can go to the bottom using M-> (usually either by combining Meta/Alt and > or by following the Escape key with >).

如果M->由于您的终端不允许您输入而无法使用,请尝试^G(同时按Control和G).这是Emacs中的取消"笔画,通常也可以与readline一起使用.

If M-> does not work because your terminal does not let you enter that, try ^G (Control and G simultaneously). That is the "cancel" stroke in Emacs and usually works with readline too.

这篇关于bash中的control-r reverse-i-search:如何“重置"搜索框?在Cygwin中进行搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆