简体   繁体   English

等于之后的Bash完成在Ubuntu上不起作用

[英]Bash completion after equals does not work on Ubuntu

On my Ubuntu 14.04.3 machine with enabled bash completion (through . /etc/bash_completion in ~/.bashrc), I do not get directory-content completion for cmd --param=<TAB> , ie, nothing is happening when pressing . 在启用了bash补全功能(通过〜/ .bashrc中的. /etc/bash_completion )的Ubuntu 14.04.3机器上,我没有获得cmd --param=<TAB>目录内容cmd --param=<TAB> ,即cmd --param=<TAB>没有任何反应。 When I start a pristine bash (eg through env -i bash --norc ), it works as expected -- but then no programmable completion is available. 当我启动原始bash时(例如通过env -i bash --norc ),它会按预期工作-但是没有可用的可编程完成功能。 I found Bash completion for path in argument (with equals sign present) which talks about a similar issue but 1) the respective npm script is not existing on my machine and 2) even removing all files from /etc/bash_completion.d does not fix the problem. 我发现参数中的路径的Bash完成(存在等号)讨论了类似的问题,但是1)我的计算机上不存在相应的npm脚本,并且2)甚至从/etc/bash_completion.d中删除了所有文件。问题。 What can I do to get proper completion? 我该怎么做才能正确完成?

I found one halfhearted fix by running complete -r -D which prevents bash from trying to complete new commands. 我通过运行complete -r -D发现了一个半心半意的修复,它可以防止bash尝试完成新命令。 This enables completion after equals again, but stops completion, for example, for killall. 这样可以在等于之后再次完成操作,但是会停止完成操作,例如,killall。

While I do not understand what you mean by "stops completion after killall", I believe there is a workaround. 虽然我不明白您所说的“在杀戮之后停止完成”的意思,但我相信有一种解决方法。

I found it here . 我在这里找到的。 It involves overriding a broken bash completion function. 它涉及覆盖损坏的bash完成功能。 Copy-pasting here for the record. 复制粘贴到此处进行记录。 The workaround is to add the following to your .bashrc : 解决方法是将以下内容添加到您的.bashrc

_completion_loader () {
  local dir=/usr/share/bash-completion/completions
  local cmd="${1##*/}"
  . "${dir}/${cmd}" &>/dev/null && return 124
  complete -o default -o bashdefault "${cmd}" &>/dev/null && return 124
}

I am uncertain whether the actual reported bug is fixed in bash: the comments in the bug report are unclear and mention a couple more problems. 我不确定实际报告的错误是否已在bash中修复:错误报告中的注释尚不清楚,并提到了更多其他问题。 For the record, my bash is version 4.2.46(1)-release (Redhat EL 7) which does have this bug. 作为记录,我的bash是4.2.46(1)-发行版(Redhat EL 7),它确实存在此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM