【发布时间】:2015-04-01 07:58:37
【问题描述】:
我有一个不支持 Readline 的 bash 实例,即这个 bash 是使用 --noediting 选项调用的。原因是这个 bash 实例被另一个程序使用了。
另一个程序想知道这个 bash 将如何完成命令行,为此它在 bash shell 中发出 compgen 命令,例如
compgen -o default I
在没有 Readline 支持的情况下,这在我的 bash 中完美运行。这是一个例子:假设我们在一个包含三个文件的目录中:
IMG_1234.JPG
about.html
index.html
compgen -o default I 命令正确打印
IMG_1234.JPG
但是现在我想切换到不区分大小写的完成。通常我在 shell 中发布
bind 'set completion-ignore-case on'
在 bash 实例中 with Readline 支持一切都如预期:compgen -o default I 打印
IMG_1234.JPG
index.html
但是在我的 bash 实例中没有 Readline 支持 bind 命令什么都不做,我仍然只得到 IMG_1234.JPG 匹配。
所以,我的问题是:如何在没有 Readline 支持的情况下在 bash 实例中设置不区分大小写的完成建议(使用 compgen 时)?
【问题讨论】:
-
尝试配置/etc/inputrc
-
我的 ~/.inputrc 文件包含
set completion-ignore-case on,但没有 Readline 支持的 bash 似乎会忽略此文件。 -
inputrc代表readline。 -
@whjm 没错!正如问题明确指出的那样,我想在“--noediting”bash(不使用 inputrc)中通过
compgen切换到不区分大小写的完成建议。
标签: bash shell gnu readline bash-completion