而不是在终端屏幕上显示所有可能性,如:
$ ls /etc/<TAB>
Display all 230 possibilities? (y or n)
Run Code Online (Sandbox Code Playgroud)
我想将所有可能性保存到一个文件中。
ls /etc/ > file.txt
不会总是有效。apt-get 就是一个例子:
$ apt-get <TAB>
autoclean check install update
autoremove clean purge upgrade
build-dep dist-upgrade remove
changelog dselect-upgrade source
Run Code Online (Sandbox Code Playgroud)
我正在寻找类似tabcompletions 'ls /etc/'
输出所有可能性的命令,以便我可以运行如下命令,该命令比较两个命令的选项卡完成可能性:
diff <(tabcompletions 'ls ') <(tabcompletions 'cd ')
Run Code Online (Sandbox Code Playgroud)
那可能吗?
在您中,~/.bashrc
您可能有这样的事情:
if [ -f /etc/bash_completion ] && ! shopt -oq posix
then
source /etc/bash_completion
fi
Run Code Online (Sandbox Code Playgroud)
现在,这就是继续查找的地方,并且 的标题_quote_readline_by_ref
包含必要的提示:
compgen -f /etc/
Run Code Online (Sandbox Code Playgroud)
追溯这一点,事实证明 (via type compgen
) compgen 是一个“shell builtin”,这意味着它应该出现在man bash
:
compgen [option] [word]
Generate possible completion matches for word according to the options ...
Run Code Online (Sandbox Code Playgroud)