PDA

View Full Version : commandline app autocomplete



psychotix
July 12th, 2012, 07:48 PM
Hi,

I'm thinking of creating a commandline utility. As a feature, I'd like it to be able to autocomplete on argument strings sort of like how bash autocompletes files or directories w/ Tab.

Is there a library out there that will allow me to do this? By pressing Tab, the utility would give suggestions for a list of options stored in a file.

Thanks,

papibe
July 12th, 2012, 07:56 PM
Hi psychotix.

A practical option is to study the current auto completion scripts. They all reside here:

/etc/bash_completion.d
Be careful not to modify them, as usually bad autocompletion scripts screw up the terminal experience :D.

Just a thought.
Regards.

Bachstelze
July 12th, 2012, 08:19 PM
That's not at all what he wants though, he wants to have Tab-completion in his program, not in Bash.

lukeiamyourfather
July 12th, 2012, 08:44 PM
The user will have to be running the program already and then give arguments instead of giving them while launching the program. The auto complete in the terminal already is done by the shell, but the shell has no way to know what your arguments are (or their options). Traditionally giving bad arguments just spits back the help.

psychotix
July 12th, 2012, 10:33 PM
I think I'll look at what papibe suggested.

Thanks!