Joined December 2017
·

awpr

Great and simple prompt; I have one improvement. GHCi's line editor (Haskeline) breaks in very confusing ways when lines wrap while using this prompt: it guesses the printed width of the prompt string incorrectly, and puts the cursor in the wrong place w.r.t. the text. The fix is to terminate ANSI escape sequences with \STX (the non-printing ASCII "start of text" character), which allows Haskeline to know the correct width of the prompt:

:set prompt "\ESC[1;34m\STX%s\n\ESC[0;34m\STXλ> \ESC[m\STX"

See https://github.com/judah/haskeline/blob/master/System/Console/Haskeline/LineState.hs#L109 for the code that makes this happen.

Achievements
1 Karma
0 Total ProTip Views