Readline and SQLite

Published 2025 July 30

One of the minor annoyances I have had with using the sqlite3 cli is that it doesn't (or so I believed) have vi bindings. I was futzing around with rlwrap and vaguely remembered that SQLite supports readline when it's available. I tested my theory in a docker container.

docker run --rm -it ubuntu:latest /bin/bash
apt-get update && apt-get install -y sqlite3

and tada!

ldd `which sqlite3` | grep readline
        libreadline.so.8 => /lib/x86_64-linux-gnu/libreadline.so.8 (0x000072653baeb000)

I enabled vi mode via set -o vi and...still no luck! Turns out that only enables it for Bash. Wait, so how do you enable vi mode for SQLite? Readline has its own configuration file. There is a global config at /etc/inputrc and a user-specific config at ~/.inputrc. So I created my own

echo 'set editing-mode vi' >>~/.inputrc

and voilĂ , the sqlite3 cli and any program that uses readline will now have the "right" keybindings. Building a comfy environment in Bash is not straightforward. My needs as a programmer have evolved and so have the problems I run into. In a surprising turn of fate, my stumbling blocks, although less excruciating, have expanded with my skillset.