uri*_*rig 2 gnu readline autocomplete
在实现GNU Readline的 shell 中,我可以单击该键以获取我开始键入的内容的可能完成列表。例如:
C:\>cd P<TAB>
PerfLogs\ Program Files (x86)\ Python27\
Program Files\ ProgramData\
Run Code Online (Sandbox Code Playgroud)
我现在如何选择我希望使用的完成方式?
我知道如果我想要上面例子中的“程序文件”,我可以输入“程序文件”,但我很懒:)。
难道没有什么方法可以让我点击键盘快捷键来遍历可能的补全,以便我可以快速选择一个吗?类似于现代 IDE 中的自动完成/智能感知?
编辑:我的解决方案可能是使用 GNU Readline 的menu-complete命令(如下所述)?但是我如何将它绑定到一个组合键呢?
menu-complete ()
Similar to complete, but replaces the word to be completed with a single match
from the list of possible completions. Repeated execution of menu-complete steps
through the list of possible completions, inserting each match in turn. At the end of
the list of completions, the bell is rung (subject to the setting of bell-style) and
the original text is restored. An argument of n moves n positions forward in the list
of matches; a negative argument may be used to move backward through the list. This
command is intended to be bound to TAB, but is unbound by default.
Run Code Online (Sandbox Code Playgroud)
在使用 的 shell 中readline,您需要绑定menu-complete到一个键。它不受默认约束,complete是。
为此,请编辑~/.inputrc并添加以下内容:
TAB: menu-complete
Run Code Online (Sandbox Code Playgroud)
这可能会影响所有使用readline. 使用以下内容仅将其应用于bash:
$if Bash
TAB: menu-complete
$endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1807 次 |
| 最近记录: |