compgen

Use compgen to get autocomplete for another command, which flag to use?

为君一笑 提交于 2019-12-20 03:40:23
问题 I have a custom auto-completed command (call it commandA ) in commandB I want to steal the autocomplete options for the first argument to commandA So, for example the options for argument1 for commandA are: abcdef abcabc abc123 I would like something along the lines of compgen -? "commandA" or compgen -? "commandA abc" to generate the list above. 回答1: You can use complete -p commandA to find out which function would be invoked to do custom completion for that command. (You need to look for

Command to list all available commands in Windows Command Prompt

走远了吗. 提交于 2019-12-12 13:07:55
问题 I’d like to programmatically get a list of all the available commands in Windows Command Prompt ( cmd.exe ). Is there something like compgen -c in Bash, but for Windows? 回答1: This provides CMD specific commands. help and to page the output use this help | more 来源: https://stackoverflow.com/questions/22158304/command-to-list-all-available-commands-in-windows-command-prompt

How do I autocomplete nested, multi-level subcommands? [duplicate]

大兔子大兔子 提交于 2019-12-10 01:56:59
问题 This question already has answers here : Multi Level Bash Completion (2 answers) Closed 2 months ago . I am trying to develop an autocomplete or tab-complete feature for my own set of commands. For example, assume foo is my binary: CLI>> foo [TAB] [TAB] It should show the main commands configure and show . Then if I select configure , it should show the subcommands CM , DSP and NPU : CLI>> foo configure [TAB] [TAB] DSP NPU CM` I only know how to tab-complete and display for the first level -

How do I autocomplete nested, multi-level subcommands? [duplicate]

拥有回忆 提交于 2019-12-04 23:51:56
This question already has answers here : Multi Level Bash Completion (2 answers) Closed last month . I am trying to develop an autocomplete or tab-complete feature for my own set of commands. For example, assume foo is my binary: CLI>> foo [TAB] [TAB] It should show the main commands configure and show . Then if I select configure , it should show the subcommands CM , DSP and NPU : CLI>> foo configure [TAB] [TAB] DSP NPU CM` I only know how to tab-complete and display for the first level - how can I get the second level as well? I will place this in /etc/completion.d . My Code: _foo() { local

Use compgen to get autocomplete for another command, which flag to use?

[亡魂溺海] 提交于 2019-12-02 00:46:40
I have a custom auto-completed command (call it commandA ) in commandB I want to steal the autocomplete options for the first argument to commandA So, for example the options for argument1 for commandA are: abcdef abcabc abc123 I would like something along the lines of compgen -? "commandA" or compgen -? "commandA abc" to generate the list above. You can use complete -p commandA to find out which function would be invoked to do custom completion for that command. (You need to look for the argument to the -F option. If there are other options, it becomes more complicated.) You would then need