Skip to content

feat: Configurable TUI keybindings via config.yaml#8297

Open
yimeng wants to merge 1 commit intoNousResearch:mainfrom
yimeng:feat/configurable-keybindings
Open

feat: Configurable TUI keybindings via config.yaml#8297
yimeng wants to merge 1 commit intoNousResearch:mainfrom
yimeng:feat/configurable-keybindings

Conversation

@yimeng
Copy link
Copy Markdown

@yimeng yimeng commented Apr 12, 2026

Summary

This PR adds support for customizing keyboard shortcuts in the interactive CLI through the
config.yaml file. This addresses the common issue where Ctrl+D conflicts with macOS terminal
behavior (forward delete character).

Changes

New Configuration Section

Added keybindings section to DEFAULT_CONFIG in hermes_cli/config.py:

keybindings:
  # Exit the application (disabled by default to preserve macOS delete-char behavior)
  exit: null
  # suspend: "ctrl+d"    # Uncomment to enable Ctrl+D exit
  
  # Suspend process to background (Unix only)
  suspend: "ctrl+z"
  
  # Insert newline in multi-line input
  newline: "ctrl+j"
  
  # Alt+Enter also inserts newline
  alt_newline: "escape+enter"

Keybinding Format

  • Keys support ctrl+x, alt+x, c-x, a-x formats (case-insensitive)
  • Multi-key sequences like escape+enter are supported
  • Set any binding to null or empty string to disable it

Modified Bindings

The following bindings are now configurable:

Action Config Key Default
Exit Hermes exit null (disabled)
Suspend to background suspend ctrl+z
Insert newline newline ctrl+j
Alt+Enter newline alt_newline escape+enter

Implementation Details

  • Added helper functions _normalize_key() and _get_keybinding() in cli.py
  • Exit keybinding defaults to null to preserve macOS delete-char behavior
  • All changes are backward compatible - existing configs work without changes

Testing

  1. Test default behavior (exit disabled):

    keybindings:
      exit: null

    Ctrl+D should perform forward delete (macOS default) or EOF (other terminals).

  2. Test enabling Ctrl+D exit:

    keybindings:
      exit: "ctrl+d"

    Ctrl+D should exit Hermes.

  3. Test custom exit key:

    keybindings:
      exit: "ctrl+\\"  # Ctrl+Backslash

Related Issues

This PR addresses the common user request to disable or rebind Ctrl+D to avoid
conflicts with terminal emulators on macOS.

@yimeng yimeng force-pushed the feat/configurable-keybindings branch from 0891cbb to e4a206d Compare April 12, 2026 09:50
Add support for customizing keyboard shortcuts in the interactive CLI
through the config.yaml file. This allows users to:

- Disable or rebind the exit key (Ctrl+D by default is now disabled
to preserve macOS delete-char behavior)
- Customize suspend (Ctrl+Z), newline (Ctrl+J), and alt_newline
(Alt+Enter) bindings
- Set any keybinding to null to disable it

Configuration format in config.yaml:
  keybindings:
    exit: null          # Disable exit keybinding
    # exit: ctrl+d    # Enable Ctrl+D to exit
    suspend: ctrl+z   # Suspend to background
    newline: ctrl+j   # Insert newline
    alt_newline: escape+enter

Key features:
- Keys support ctrl+x, alt+x, c-x, a-x formats (case-insensitive)
- Multi-key sequences like escape+enter are supported
- Defaults are set for all bindings except exit (disabled by default)
- Backward compatible: existing configs work without changes
@yimeng yimeng force-pushed the feat/configurable-keybindings branch from e4a206d to ebfdef2 Compare April 12, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant