.inputrc as a Workaround for Clearing Screen in vi Mode

All the cool kids are setting their shells to vi mode by adding

set -o vi

to their .bashrc. I’ve been going back and forth myself, as I like the improved editing of vi mode on the command line but don’t enjoy the hassle of having to reenter insert mode after inadvertently entering normal mode.

vi mode does have the drawback that it disables a terminal emulator’s CTRL+L shortcut for clearing the screen in insert mode. If I have to leave insert mode, press CTRL+L, and reenter insert mode, I might as well type clear. A faster solution is needed.

Enter .inputrc: this file allows the formulation of aliases or macros bound to key combinations. To emulate normal CTRL+L behaviour in vi insert mode, I’ve added the following lines to ~/.inputrc:

set keymap vi-insert

$if Bash
    "\C-l": "\e\C-la"
posted by paul on 27 june mmxviii at 03:05 EST
blog comments powered by Disqus