Bash: autocomplete from list

Tom H tomh0665 at
Sun Aug 1 20:50:33 UTC 2010

On Sun, Aug 1, 2010 at 9:46 AM, Hal Burgiss <hal at> wrote:
> On Sun, Aug 1, 2010 at 9:22 AM, Luis Paulo <luis.barbas at> wrote:
>> On Sun, Aug 1, 2010 at 1:23 AM, Afsheen Ghorashy <grasswistle at> wrote:
>>> Let us assume that I have a text file with expressions separated by line
>>> breaks.
>>> I would like Bash to include the expressions of this text file in its search
>>> when I press double-tab (autocomplete).
>>> Is this possible? How would I do it? Programming is no foe of mine.
> It would be worth looking at some programmable completion tutorials.
> Programmable completion  is available with bash and allows for
> customizing the completion options. Its pretty flexible.

The on the url above is very similar to the scripts in
"/etc/bash_completion.d" but I am not sure that it is entirely
applicable in your case; you will have to create specific scripts for
each expression in your file. You have to ensure that bash completion
is uncommented (I think that it is by default by I replace these files
without looking at them so I don't know) in .bashrc.

I have some custom ones for the initctl commands - start, stop,
restart, reload - so I can type, for example, "sto<tab> av<tab>"
instead of typing "sto<tab> avahi-daemon". So, AFAIK, it is only
useful if you have a two-word command. For one-word commands, you
should create aliases.

More information about the ubuntu-users mailing list