【发布时间】:2020-12-28 11:53:51
【问题描述】:
目前这是我的 ghci 提示符的样子:
我想让它看起来像这样:
或者像这样
关于如何做到这一点的任何想法?我的配置(ghci.conf)文件的内容如下所示
:set prompt "\ESC[33m\STX[%s]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
其中我遵循了上面写的语法:
【问题讨论】:
目前这是我的 ghci 提示符的样子:
我想让它看起来像这样:
或者像这样
关于如何做到这一点的任何想法?我的配置(ghci.conf)文件的内容如下所示
:set prompt "\ESC[33m\STX[%s]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
其中我遵循了上面写的语法:
【问题讨论】:
您可以使用prompt-function 而不是prompt 为提示符运行更高级的Haskell 函数。这是第二个提示的示例ghci.conf:
:{
prompter :: [String] -> Int -> IO String
prompter modules line = return $
concat [ "\ESC[33m\STX["
, Data.List.intercalate ", " modules
, "]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
]
:}
:set prompt-function prompter
或者,对于数字,您可以使用zipWith:
:{
prompter :: [String] -> Int -> IO String
prompter modules line = return $
concat [ "\ESC[33m\STX["
-- this is the only line that changed
, Data.List.intercalate ", " $ zipWith (\n m -> concat [show n, ".", m]) [1..] modules
, "]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
]
:}
:set prompt-function prompter
我将把它作为编写续行的练习,但它非常相似,只涉及prompt-cont-function。