KSH Reverse History Search

Posted by Tully on Mon 10 March 2014

I recently switched from using the bash shell to the Korn Shell and noticed that a lot of my key bindings were no longer working. I run Centos as my Linux distro of choice and installed KSH via YUM.

Install KSH on Centos

yum -y install ksh

After switching my shell to use KSH, I set the key bindings to VI. In BASH the default is set to EMACS key bindings. When I switched to VI bindings this caused all the normal bindings like CTRL^R (Reverse History Search), CTRL^E (Go to end of line), and other commands to no longer work. I wanted the reverse history keybindings to work again.

Adding reverse history keybinding to KSH VI Mode

Open your .zshrc config file

vi $HOME/.zshrc

Add the following

bindkey -v  
bindkey '^R' history-incremental-search-backward

Save and source the configuration

source $HOME/.zshrc

The key binding CTRL^R for reverse searching history should now work.