How to customize Readline keybindings of GHCi?

江枫思渺然 提交于 2019-12-21 08:17:09

问题


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.


回答1:


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



回答2:


@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).



来源:https://stackoverflow.com/questions/1825547/how-to-customize-readline-keybindings-of-ghci

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!