I try to use terminal colors within my ghci prompt.
So when I open ghci
and try to:
Prelude> :set prompt '\[\033[1haskell > \033[0m\]'
'\[\033[1\]haskell> \[\033[0m\] '
I know that these codes are interpreted by bash with echo
and the -e
flag. But how can I do this within ghci?
According to https://wiki.haskell.org/GHCi_in_colour, you can use
:set prompt "\ESC[33m\STXhaskell > \ESC[m\STX"
A few notes of explanation:
\STX
corresponds to the \]
of your bash
prompt; \[
as well. (Perhaps it does; I haven't played with this much.)Haskell character escape codes are in decimal:
Prelude> :set prompt "\027[31mhaskell>\027[0m "
Putting the same directive in your .ghci
file should also work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With