Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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).

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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