I'm wondering if it's possible to make autocompletion span an = sign. So, for example, I want to type foo BAR=[TAB][TAB]
, and have it fill in the possible values for BAR
. I've tried the following: I have a file called 'bar', as follows:
#!/bin/bash
echo -e "BAR=100\nBAR=110\nBAR=200" | grep "^$2"
And then I do:
~> complete -C bar foo
If I type foo [TAB][TAB]
, it gives me some possible values for BAR. If, I type foo BAR=[TAB][TAB]
, it fails (it appends BAR=BAR=
to the end of the command). (note, if I type bar 1 BAR=
, it gives me a proper list of completions, so this is not an issue with the bar script).
This would be very useful for some scripts I have.