|Version 2 (modified by judah, 5 years ago)|
Control Sequences in the Prompt String
As of version 0.6.3 (#78), Haskeline will compute the correct width for input prompts that contain POSIX escape sequences such as color changes. However, the ending must be indicated in the prompt string, since there's no way for Haskeline to detect it automatically.
The ending is denoted by the control character '\STX' (i.e., ASCII '\002'). Any substring in the prompt of the form "\ESC...\STX" will be treated as zero-width for the purposes of line-breaking.
prints out the prompt string "Prompt:" in green text. The first escape sequence ("\ESC[1;32m\STX") changes the text color to green, and the second ("\ESC[0m") turns the color back to normal.
If GHC (or the ghci-haskeline package) has been compiled against haskeline-0.6.3 or newer, adding the following line to your ~/.ghci file will turn the prompt string green:
:set prompt "\SOH\ESC[1;32m\STX%s>\SOH\ESC[0m\STX"