我希望该命令默认启用 Tab 补全功能,firefox
这样我就能轻松打开当前文件夹中的任何文件/文件夹,而不仅仅是那些匹配的文件/文件夹@(?([xs])htm?(l)|pdf|txt)
(也就是来自 的正则表达式/usr/share/bash-completion/completions/firefox
)。例如,我会Readme.md
在 Firefox 中打开 Markdown 文件(例如 ),因为我有一个插件可以很好地渲染这些文件。
Stack Exchange 网络中有很多关于此问题的问题,有些正确地建议这样complete -r firefox
做,但这似乎只是暂时的。以下是一些伪 bash 命令:
$ ls
foo.txt Readme.md bar.adoc
$ firefox <TAB> # only completes foo.txt
$ complete -p firefox
complete -F _firefox firefox
$ complete -r firefox # try to disable it
$ complete -p firefox
bash: complete: firefox: no completion specification
$ firefox <TAB> # only completes foo.txt
$ complete -p firefox
complete -F _firefox firefox # it's baaaaack!
$ complete -r
$ firefox <TAB> # completes all 3 files
最后那个complete -r
命令确实有效,但我不想太过繁琐。我想保留其他命令的特殊完整功能。
如果我无法彻底删除firefox
我的自定义 Tab 补全功能~/.bashrc
,我想接下来我会尝试手动删除/usr/share/bash-completion/completions/firefox
(以及其他一些提到 Firefox 的功能)。如果可能的话,我希望避免弄乱软件包里的文件bash-completion
。
我使用的是 Ubuntu 22.04 自带的默认 Bash (v5.1.16)。为了方便起见,我使用了 gnome-terminal。