Send Feedback
Skip to content

Embedded Line Editor (kxline)

This page describes kxline, the embedded line editor used by KDB-X 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

kxline is the embedded line editor used by KDB-X 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

The following sections describe the line-editing and command history features available in kxline interactive sessions.

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 may require Fn + Delete/, depending on keyboard and terminal.
  • Home/End behavior is commonly accessed using Fn + Left/Right.

Session history

kxline maintains a persistent command history across interactive sessions.

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

    • Type to search.
    • Use Backspace to erase.
    • Cancel with Ctrl+G.
  • Read the history file ~/.q_history on startup and append to it on exit.

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.

Example of forcing interactive mode in a pipe:

cat | KX_TTY=1 q

Next steps