How to autocomplete a bash commandline with file paths?

前端 未结 1 1929
攒了一身酷
攒了一身酷 2021-01-16 00:02

Context

I am creating a shell program which is a command line tool. I want to create my own auto-completion for this tool.

I want to do two different thing

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 00:45

    To auto complete file paths

    Substitute

    complete -F __my_app_autocomplete my_app
    

    with

    complete -o filenames -F __my_app_autocomplete my_app
    

    Here you can find all the compgen options explained:

    https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html

    0 讨论(0)
提交回复
热议问题