0

I know if I want tab completion I can use

char *readline (const char *prompt);

and I'll get tab completion while it's running, but what if I already have a string that I want to be completed? Is there a specific function in the readline library that I can call directly and send the string as a parameter to have it run tab completion on it?

I've read through a lot of the source code of complete.c to find a main function I could send a string to with no luck.

alk
  • 69,737
  • 10
  • 105
  • 255
Josh Wein
  • 65
  • 4
  • 12
  • 1
    You can take a look at [this](http://web.mit.edu/gnu/doc/html/rlman_2.html#SEC36) link for information how. – Linus Oct 30 '15 at 21:22
  • It looks interesting, I'm not sure if any of the functions let me give them a string to complete though. The biggest one rl_complete() needs an int ignore and an int invoking_key which I think come from a running readline? – Josh Wein Oct 31 '15 at 02:43

1 Answers1

1

I don't know exactly where the C side API lives, but from the BASH side calling of stuff, compgen can accept "partial" input.

The main problem is that the "partial" input is typically provided to shell scripts located in /usr/share/bash-completion/completions/"program", so there is a chance that what you seek is not actually "C API" but the output of one or more bash scripts.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138