bash-completion - completion function defined the first time a command is invoked

后端 未结 3 2013
醉梦人生
醉梦人生 2020-12-09 23:46

I\'ve added a new alias scp_using_rsync, which uses rsync to copy files over SSH with certain options. I wanted to link the bash completion for scp to this alia

3条回答
  •  一整个雨季
    2020-12-10 00:06

    Bash 4.1 added a new -D option for complete, compgen and compopt:

    New complete/compgen/compopt -D option to define a `default' completion: a completion to be invoked on command for which no completion has been defined. If this function returns 124, programmable completion is attempted again, allowing a user to dynamically build a set of completions as completion is attempted by having the default completion function install individual completion functions each time it is invoked.

    There's an example from bash's manual:

    _completion_loader()
    {
         . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
    }
    complete -D -F _completion_loader
    

提交回复
热议问题