我有一个容器,其中的 shell 运行 bash。它安装了 bash 补全功能,运行良好。此容器有许多自定义 cli 命令,但它们都必须以 开头nextcloud
。因此,如果我输入nex <tab>
nex,它就足够独特,可以完成。
有没有办法在新的 cli 行(空白)上设置“默认”完成,以便第一个选项卡注入该默认值,或者我可以在nextcloud
不使用选项卡的情况下进行注入。
我搜索了“bash 补全”和 bash 手册页以及 complete 的帮助。我尝试了 -D、-E,根据措辞,这似乎是可行的,但我不知道该怎么做。能帮点什么吗?
https://opensource.com/article/18/3/creating-bash-completion-script
https://linux.die.net/man/1/bash(搜索页面Completing
)
complete: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
Specify how arguments are to be completed by Readline.
For each NAME, specify how arguments are to be completed. If no options
are supplied, existing completion specifications are printed in a way that
allows them to be reused as input.
Options:
-p print existing completion specifications in a reusable format
-r remove a completion specification for each NAME, or, if no
NAMEs are supplied, all completion specifications
-D apply the completions and actions as the default for commands
without any specific completion defined
-E apply the completions and actions to "empty" commands --
completion attempted on a blank line
-I apply the completions and actions to the initial (usually the
command) word
When completion is attempted, the actions are applied in the order the
uppercase-letter options are listed above. If multiple options are supplied,
the -D option takes precedence over -E, and both take precedence over -I.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.