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
COMPREPLY=()
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With