I've installed program trickle that allow to throttle the net for specified command like:

trickle -u10 -d10 <COMMAND>

How to add bash completion for all binaries to trickle command?


Do you have, and load, the file /etc/bash_complete or an equivalent directory? It defines a bunch of completions and extension facilities beyond what's built into bash. If you have access to them, you can probably just use

complete -o filenames -F _command trickle

It will complete the first argument of trickle as a command, and will then try to apply appropriate completion rules for subsequent arguments. But it depends on the shell function _command, which is defined in the above file (in my Debian system, at least). YMMV on other Linux distributions, and the file doesn't seem to be present in Darwin (OS X 10.8).


Actually there's an even simpler way to do this:

complete -c trickle

which will add completion of all available commands. If you wanted to do something fancy for the -u, -d etc. options there's some useful information here.

As an aside: the man documentation for complete is pretty understandable but it's buried way down in the enormous bash manpage. The html version is much easier to get at.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.