我需要能够更改运行 c 文件的可执行文件时的提示以获得自定义提示
例如:
$ abc
abc>
在这里用户可以给出程序可接受的命令。 我看到这种情况发生在像 MySQL 这样的程序上,我想知道是否可以这样做。
最佳答案
您可以使用 gnu readline用于自定义提示
#include <readline/readline.h>
#include <readline/history.h>
while (1)
{
command = readline ("$abc");
command = readline ("abc>");
//validate your command name
system(command);
add_history (command); ///add command in history
}
关于linux - 输入命令时更改命令提示符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22347840/