How can I set my GHCi prompt to a lambda character

2019-01-22 20:08发布

I want to have a lambda (λ) symbol as my prompt in GHCi (7.8) on Windows 7, so I set up my .ghci file as

:set +m
:set prompt  "λ: "
:set prompt2 " | "

And I set my console font to Lucida Console since it's supposed to support Unicode, but when I load up GHCi, it looks like this instead

no lambda!

How can I get Windows to recognize the λ symbol properly?

2条回答
▲ chillily
2楼-- · 2019-01-22 20:32

This is actually quite a simple fix, just run the following command before starting GHCi:

> chcp.com 65001

This sets Window's encoding to the 65001 code page, which lets the λ get displayed properly:

enter image description here

This will also let a lot of other Unicode characters be displayed properly in cmd.exe and other Windows shells (such as Cygwin bash), but Windows' Unicode support is still not perfect, and some fonts don't support many of the characters. Luckily, λ happens to be a supported character so we can all have the classic GHCi prompt.

查看更多
小情绪 Triste *
3楼-- · 2019-01-22 20:54

Using > chcp.com 65001 worked with ghci but opening other text files with vim after setting that code page returned garbled text.

Instead of changing the code page you can use unicode escaped lambda \x03BB:

:set prompt  "\x03BB: "

instead of:

:set prompt  "λ: "
查看更多
登录 后发表回答