Wednesday, March 25, 2009

vi command line history in ghci

There are a few resources that explain how to activate vi command line history within ghci. Some of them propose to use rlwrap. However, these didn't seem to work for my situation:
  • Mac OS X 10.4.11 (Tiger)
  • GHC 6.10.1 (installed with MacPorts)
The reason being that my version of GHC does not use readline but rather editline. So the configuration is not ~/.inputrc but ~/.editrc, which in my case contains:
bind -v

To enable persistent history create directory ~/.ghc, so ghci can maintain the file ~/.ghc/ghci_history persistent between sessions. The default is a history of 100 commands but you can change that by adding this line to your ~/.ghc/ghci.conf:
System.Console.Editline.Readline.stifleHistory 1000
which would increase your history to 1000 commands.

I didn't find any explicit documentation about ghci command history configuration, but rather cobbled it together from patch files and developer mailing lists.


  1. Thanks! This really helped me out.

  2. Modern version is here: