note 124558 added to features.commandline.interactive
| From: | Gray@php.net | Date: | Thu, 02 Jan 2020 11:53:01 +0000 |
| Subject: | note 124558 added to features.commandline.interactive | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213721@lists.php.net to get a copy of this message | ||
When adding colours, don't forget that PHP uses the same 'readline' as Bash does, so
it has the same need to wrap all colour codes in special marker characters.
If you simply add raw colour codes to the prompt, you will notice that long lines no longer get
wrapped correctly -- Readline no longer knows how wide the prompt is.
To fix this, you need to start each colour code with an '0x01' byte (aka Ctrl-A aka SOH)
and end it with the '0x02' byte (aka Ctrl-B aka STX). There are no escapes for these --
you have to literally put the control characters in your php-cli.ini.
For example:
<?php
// cli.prompt = <SOH>\e[1m<STX> PHP! \> <SOH>\e[m<STX>
echo "cli.prompt = \x01\\e[1m\x02 PHP! \x01\\e[m\x02\n";
?>
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.168 (proxied: 2001:778:e27f:a23:36c4:e19f:3c1:8a8)
----
Manual Page -- http://php.net/manual/en/features.commandline.interactive.php
Edit -- https://master.php.net/note/edit/124558
Del: integrated -- https://master.php.net/note/delete/124558/integrated
Del: useless -- https://master.php.net/note/delete/124558/useless
Del: bad code -- https://master.php.net/note/delete/124558/bad+code
Del: spam -- https://master.php.net/note/delete/124558/spam
Del: non-english -- https://master.php.net/note/delete/124558/non-english
Del: in docs -- https://master.php.net/note/delete/124558/in+docs
Del: other reasons-- https://master.php.net/note/delete/124558
Reject -- https://master.php.net/note/reject/124558
Search -- https://master.php.net/manage/user-notes.php