Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 958fd44774
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (27 sloc) 0.758 kb
#include <stdio.h>
#include <stdlib.h>
#include "linenoise.h"
#ifndef NO_COMPLETION
void completion(const char *buf, linenoiseCompletions *lc) {
if (buf[0] == 'h') {
linenoiseAddCompletion(lc,"hello");
linenoiseAddCompletion(lc,"hello there");
}
}
#endif
int main(void) {
char *line;
#ifndef NO_COMPLETION
linenoiseSetCompletionCallback(completion);
#endif
linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
while((line = linenoise("hello> ")) != NULL) {
if (line[0] != '\0') {
printf("echo: '%s'\n", line);
linenoiseHistoryAdd(line);
linenoiseHistorySave("history.txt"); /* Save every new entry */
}
free(line);
}
return 0;
}
Jump to Line
Something went wrong with that request. Please try again.