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/RightandHome/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
Controlmaps toCtrl.Optionmaps toAlt.- 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/RightforHome/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
Backspaceto erase. - Cancel with
Ctrl+G.
Fixed history file location
kxline always uses ~/.q_history for command history. The path is not configurable.
Configuration¶
kxlineruns by default when q detects an interactive terminal (TTY).- To disable
kxline, setKX_LINE=0before 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¶
- Explore available system commands in system commands.
- Learn the wider terminal workflow in how to use the q terminal.