开发者

Preserve Bash Completion for all commands that are prepended by a custom command

开发者 https://www.devze.com 2023-02-28 11:44 出处:网络
I have a script which allows to execute Bash processes in the background, i called it \"backy\". Programs I want to run in background I call like this:

I have a script which allows to execute Bash processes in the background, i called it "backy". Programs I want to run in background I call like this:

backy long-running-script param1 param2

The problem is now that I loose the Bash completion for long-running-script if I prepend another script.

I want to write a Bash completion file which preserves not only the Bash completion for long-running-script and all of its parameters, also for every other script that I want to call with backy.

I have some experience with Bash completion, but I'm just missing the command which I can insert into my Bash completion script so that it completes with the completion of the script that is to be called. Any ideas?

My completion so far:

have backy &&
_backy_complete()
{
  local cur prev goals

  COMPREP开发者_JAVA技巧LY=()
  cur=${COMP_WORDS[COMP_CWORD]}

  # How to get the completion from the script that is the param for backy, 
  # in a generic way?
  COMPREPLY=( ????? )
  return 0
} &&
complete -F _backy_complete backy

EDIT - SOLUTION:

Thanks to Lekensteyn, I replaced the content of my existing bash completion script with just this line:

complete -F _command backy


There is already a bash_completion function for such cases:

complete -F _command backy

It's used for autocompleting the commands after sudo, fakeroot and others. Any arguments passed to backy are ignored like:

backy --whatever --this --is=ignored not ignored anymore
0

精彩评论

暂无评论...
验证码 换一张
取 消