Linux反向写入内容,在Linux中取消bash中的反向搜索失败,但保留我输入的内容

我每次运行命令时都会按Ctrl R,但输入一个单词后(例如查找)我发现命令不在我的历史记录中,所以我按预期得到了这个:

(failed reverse-i-search)`find`: cat fire.txt

现在如何取消搜索,但在命令行中保持“查找”?无论什么键,我按’cat fire.txt’都会在我的命令行上结束,我必须擦除并重新输入我的命令.

我正在使用Ubuntu.谢谢.

我不知道你可以完全按照自己的意愿行事,但你可以隐约接近(尽管它牺牲了反向搜索的其他功能).

将键序列绑定到history-search-backward并通过键入起始单词然后按下绑定序列来进行搜索.

history-search-backward ()

Search backward through the history for the string of characters between the start of the current line and the point. The search string must match at the beginning of a history line. This is a non-incremental search. By default, this command is unbound.

但这仅适用于以您要搜索的单词开头的命令(以及不是增量的).

更新:刚刚发现,在寻找其他东西时,在bash NEWS for 4.3中有一个条目说

b. There are new bindable commands to search the history for the string of

characters between the beginning of the line and the point

(history-substring-search-forward, history-substring-search-backward)

因此,这意味着使用足够新的readline版本(即NEWS的readline部分),您仍然可以使用此版本进行子字符串历史记录搜索.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值