如何自定义 GHCi 的 Readline 键绑定?

发布于 2024-08-12 12:44:30 字数 134 浏览 4 评论 0原文

我知道 GHCi 支持 Readline,并且 ^W^U 等键绑定可以按预期工作。

我确实想知道 ghci 是否支持自定义键绑定,就像 Bash 处理 inputrc 的方式一样。

I know GHCi supports Readline, and keybindings such as ^W and ^U work as expected.

I do wonder whether ghci support customization of keybindings the way Bash deals with inputrc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

熊抱啵儿 2024-08-19 12:44:30

你的 GHC 版本是什么? GHCi 停止使用 readline,并在 6.10 左右开始使用 libedithaskeline 6.12 左右。

libedit 可以在 ~/.editrc< 中配置/a>;同样,Haskeline 有 ~/.haskeline。例如,我必须

# ~/.editrc (for libedit)
edit on
bind ^R em-inc-search-prev
bind ^S em-inc-search-next
bind ^[[5~ ed-search-prev-history
bind ^[[6~ ed-search-next-history

匹配我的

# ~/.inputrc (for readline)
"\e[5~": history-search-backward
"\e[6~": history-search-forward

What is your GHC version? GHCi stopped using readline and started using libedit around 6.10 and haskeline around 6.12.

libedit can be configured in ~/.editrc; similarly, Haskeline has ~/.haskeline. For example, I have

# ~/.editrc (for libedit)
edit on
bind ^R em-inc-search-prev
bind ^S em-inc-search-next
bind ^[[5~ ed-search-prev-history
bind ^[[6~ ed-search-next-history

to match my

# ~/.inputrc (for readline)
"\e[5~": history-search-backward
"\e[6~": history-search-forward
み格子的夏天 2024-08-19 12:44:30

@ephemient 上面的答案也对已从 readline 切换到 libedit 的较新版本的 MySQL 有所帮助。我曾经

$ ~/.editrc:
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

匹配我的旧版本,它曾经在MySQL中工作:(

$ ~/.inputrc:
"\e[A":history-search-backward
"\e[B":history-search-forward

现在我唯一的烦恼是,如果我只想滚动而不是搜索,我必须先输入一个“.”来匹配每一行)。

@ephemient's answer above also helps with newer builds of MySQL which have switched from readline to libedit. I used

$ ~/.editrc:
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

to match my old version which used to work inside MySQL:

$ ~/.inputrc:
"\e[A":history-search-backward
"\e[B":history-search-forward

(my only annoyance now is that if I just want to scroll and not search, I have to type a "." first to match every line).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文