直接调用readline()的Tab键完成

时间:2015-10-30 21:13:28

标签: c readline libreadline

我知道如果我想要标签完成我可以使用

char *readline (const char *prompt);

并且我会在它运行时获得标签,但是如果我已经有一个我想要完成的字符串怎么办? readline库中是否有一个特定的函数可以直接调用并将该字符串作为参数发送给它以使其在其上运行Tab键完成?

我已经阅读了很多complete.c的源代码,找到了一个我可以发送字符串的主要功能而没有运气。

1 个答案:

答案 0 :(得分: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.