Skip to content

Embedded line editor (kxline)

This page describes kxline, the embedded line editor KDB-X uses when you interact with the q terminal. It explains how kxline behaves in an interactive session, how to control it using environment variables, and which line-editing and history features it provides.

Overview

KDB-X uses kxline as its embedded line editor for interactive q sessions on Linux and macOS. It provides basic line editing and session history. This removes the need to install and use external tools such as rlwrap for most terminal-based workflows.

Windows console behavior

On Windows, KDB-X relies on the native console behavior provided by the operating system rather than kxline. Refer to Keyboard shortcuts in Windows.

Supported features

Line editing

kxline provides single-line editing only. Supported actions include:

  • Delete character before cursor: Backspace (Ctrl+H)
  • Delete character after cursor: Delete (Ctrl+D)
  • Move cursor: Left/Right and Home/End (Ctrl+A/Ctrl+E)
  • Move cursor by word: Ctrl+Left/Ctrl+Right (Alt+B/Alt+F)
  • Delete previous word: Ctrl+W
  • Delete to beginning or end of line: Ctrl+U/Ctrl+K

Mac key equivalents

  • Control maps to Ctrl.
  • Option maps to Alt.
  • The Delete (⌫) key deletes the character before the cursor (backspace behavior).
  • Forward delete might require Fn + Delete (⌫), depending on keyboard and terminal.
  • Press Fn + Left/Right for Home/End.

Session history

kxline maintains a persistent command history across interactive sessions. It reads ~/.q_history at startup and appends to it on exit.

  • Navigate history using Up/Down.
  • Search history with Ctrl+R.

    • Enter your search text.
    • Use Backspace to erase.
    • Cancel with Ctrl+G.

Fixed history file location

kxline always uses ~/.q_history for command history. The path is not configurable.

Configuration

  • kxline runs by default when q detects an interactive terminal (TTY).
  • To disable kxline, set KX_LINE=0 before starting q.
  • To force q to run interactively regardless of TTY detection, set KX_TTY=1.

To force interactive mode in a pipe:

cat | KX_TTY=1 q

Next steps