Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize Readline keybindings of GHCi?

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.

like image 229
Adaptee Avatar asked Dec 01 '09 11:12

Adaptee


2 Answers

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
like image 98
ephemient Avatar answered Oct 15 '22 04:10

ephemient


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

like image 35
BrentHarsh Avatar answered Oct 15 '22 05:10

BrentHarsh