Skip to content

TUI: support zsh-style Ctrl+U as a configurable line-kill command #20698

Done

Description

@joshka

What variant of Codex are you using?

CLI / TUI

What feature would you like to see?

Add separate configurable editor commands for the two common Ctrl+U line-editing semantics:

  • kill_line_start: kill from the beginning of the current line to the cursor
  • kill_whole_line: kill the current line regardless of cursor position

The TUI currently binds Ctrl+U to kill_line_start, which matches Bash/Readline. That should remain configurable.

However, zsh's default emacs keymap binds ^U to kill-whole-line, and macOS uses zsh as its default shell. For the common macOS/zsh case, Ctrl+U should clear the current line by default, while Bash/Readline users should be able to restore the existing behavior through [tui.keymap.editor].

The simple approach is probably best:

  • Add kill_whole_line.
  • Default Ctrl+U to kill_whole_line, following zsh/macOS.
  • Keep kill_line_start available as a configurable action for users who prefer Bash/Readline behavior.

This was also the primary papercut I had in mind when I originally started working on configurable keymaps: Ctrl+U is a small shortcut, but it is frequent enough that the wrong line-editing semantic becomes noticeable quickly.

Additional information

Relevant upstream behavior:

This builds on #18593 by @fcoury-oai, which introduced configurable TUI keymaps.

A more user-adaptive version could choose the default from the user's shell configuration. For zsh, this is easy to inspect:

zsh -fc 'bindkey -e; bindkey "^U"'

On a stock zsh setup this reports:

"^U" kill-whole-line

For Bash/Readline, the current binding can be inspected with:

bash -ic 'bind -P | grep -E "^(unix-line-discard|backward-kill-line|kill-whole-line)"'

On a typical Bash/Readline setup this reports:

backward-kill-line can be found on "\C-x\C-?".
kill-whole-line is not bound to any keys
unix-line-discard can be found on "\C-u".

unix-line-discard corresponds to the existing Codex behavior: kill backward from the cursor to the beginning of the current line.

That said, shell probing is probably gold plating. It is more customer-friendly in principle, but it adds startup/runtime complexity and edge cases:

  • probes may source user startup files
  • probes may emit job-control warnings without a real TTY
  • shell configs can be slow or have side effects
  • $SHELL may not match the terminal/editor behavior the user expects inside Codex
  • Windows behavior has not been considered here

A simple static default plus explicit configuration is likely easier to implement, document, test, and reason about. The adaptive heuristic can be treated as a future enhancement if maintainers think it is worth the extra complexity.

Existing implementation notes:

  • The TUI currently has editor.kill_line_start and editor.kill_line_end.
  • Ctrl+U currently defaults to editor.kill_line_start.
  • The textarea handler maps that action to kill_to_beginning_of_line().

Relevant local files:

  • codex-rs/tui/src/keymap.rs
  • codex-rs/tui/src/bottom_pane/textarea.rs

Related issues and PRs:

Activity

  1. added
    enhancement
    CLI
    TUI
    config
    on May 1, 2026
  2. removed
    CLI
    on May 1, 2026
  3. etraut-openai commented on Nov 27, 2026

    @etraut-openai
    Contributor

    The editor now supports both actions. To make Ctrl+U delete the whole line regardless of cursor position, add these bindings to config.toml:

    [tui.keymap.editor]
    kill_line_start = []
    kill_whole_line = "ctrl-u"

    The empty list clears the existing binding so the two actions don’t conflict. Without this change, Ctrl+U still deletes from the cursor back to the start of the line.

    Closing as implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIconfigenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions