The following program prints a colorized readline prompt. It breaks control-a (the cursor ends up much farther to the right than it should be):
#include <readline/readline.h>
#include <readline/history.h>
#define CYELLOW "\001\e[0;31m\002"
#define RESET "\001\e[0m\002"
int main(int argc, char **argv)
{
readline(CYELLOW "prompt> " RESET);
return 0;
}
control-a works when I call readline() without a colorized prompt:
readline("prompt> ");
I'm using Mac OS X 10.9.4. Here's the output of otool:
/usr/lib/libreadline.dylib:
/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1
There are a couple of stackoverflow questions that seem to touch on this:
Both of them mention that color markers need to be bracketed by \001 and \002. I followed those instructions but control-a is still broken.