Page 1 of 1

change color of readline_callback_handler_install

Posted: Thu Jun 03, 2021 5:39 am
by McLotos
Hello guys! I try to set a two different colors - blue color for "command>" and magenta for inputed text, but it not work, because readline_callback_handler_install not allow a color codes.
Image
Somebody know a simple solution?

Re: change color of readline_callback_handler_install

Posted: Sun Jun 06, 2021 4:49 am
by simonbrahan
There's no way to do it directly. You could spoof it by echoing your prompt manually then having a blank "prompt" in your readline handler. The example below shows how it works with readline().

Code: Select all

echo "\e[0m\e[34m Wacky coloured prompt: \e[0m";
$foo = readline('');