触发没有pressing Ctrl + R键在bash反向我搜索的替代方法 [英] alternate way to trigger reverse-i-search without pressing ctrl+r in bash

查看:185
本文介绍了触发没有pressing Ctrl + R键在bash反向我搜索的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash反向I-搜索工具是有用的,但它不像大多数其它的bash命令,它似乎被绑定到一个按键绑定(<大骨节病>控制 + <大骨节病>研究)。如何使用别名或用户触发此工具键入的命令呢?

The reverse-i-search facility in bash is useful, but it is unlike most other bash commands in that it seems to be bound to a keybinding (Ctrl + R). How can a user trigger this facility using an alias or typed-in command instead?

推荐答案

反向我搜索功能实际上是一个readline的功能(反向搜索历史),而不是一个bash内建函数(男内置或看到的内置在Bash参考手册命令)。据我所知是没有办法调用它绑定到一个键以外的readline功能。

The reverse-i-search function is actually a readline function (reverse-search-history) and not a bash builtin function (man builtin or see builtin commands in the bash reference manual). To my knowledge there is no way to call a readline function outside of binding it to a key.

您可以看到所有使用readline的按键绑定到这些功能绑定-l -p 绑定的readline的命令列表可以发现在参考手册以及

You can see all the readline key binding to these function using "bind -l -p". The list of bindable readline commands can be found in the reference manual as well.

您可以随时使用历史命令来获取历史列表,并使用的grep 来找到你正在找。我自己,我觉得这是有用的:

You can always use the history command to get a list of the history and use grep to find what you are looking for. Myself I find this to be useful:

alias hists="history | grep -v '^ *[0-9]* *hists' | grep $@"

当我运行 hists东西我得到一个匹配的东西所有命令的列表。我所要做的就是然后做!#运行命令。例如:

When I run hists something I get a list of all the commands that matches something. All I have to do is then do !# to run the command. For example:

bash-3.2$ hists emacs
   30 emacs
  128 emacs
  129 emacs
  204 emacs
  310 emacs .bash_history
  324 emacs Documents/todo.txt
bash-3.2$ !324

这不正是你在找什么,但它尽可能靠近我能做到这一点。

It's not exactly what you are looking for but it's as close as I can make it.

这篇关于触发没有pressing Ctrl + R键在bash反向我搜索的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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