Bash不会自动完成文件的(Tab) [英] Bash will not auto-complete (Tab) with files
问题描述
bash中的自动完成功能(带有Tab)可在文件夹上使用,但不能用于文件.
Auto-completion in bash (with Tab) works on folders, but not with files.
- 我正在运行Ubuntu 13.10
- 我没有触摸过 .bashrc 文件
这是 .bashrc 文件底部的外观,其中安装并更新了 bash-completion 部分:
This is how the bottom part of the .bashrc file looks, with the bash-completion part installed and updated:
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
有什么想法吗?
推荐答案
有时很难预测第三方"bash_completion"软件包(不要与bash或其本机完成混淆).
The third party "bash_completion" package (not to be confused with bash or its native completion) can sometimes be hard to predict.
- 专门将某些命令设置为永远不会完成文件,例如
cd
- 某些命令将拒绝填写某些文件名,因为bash_completion并未意识到程序会处理它们,例如
mplayer
. - 某些命令只是个错误,特别是当路径包含空格和其他字符时,例如
scp
.
如果您遇到的情况不是bash_completion没有帮助,则可以使用 M-/
(又名 Alt +/
)来使用bash的本机文件名代替完成.
If you're ever in a situation where bash_completion isn't being helpful, you can use M-/
(aka Alt + /
) to use bash's native filename completion instead.
如果命令经常给您带来麻烦,则可以在 .bashrc
末尾使用 complete -r thatcommand
禁用此命令的bash_completion.
If a command is frequently giving you trouble, you can disable bash_completion for this command using complete -r thatcommand
at the end of your .bashrc
.
这篇关于Bash不会自动完成文件的(Tab)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!