Skip to content

Support macOS line-editing shortcuts in the terminal - #4760

Closed
robennals wants to merge 1 commit into
get-bb:mainfrom
robennals:bb/add-standard-keyboard-shortcuts-to-the-bb-thr_nttab8umdq
Closed

robennals wants to merge 1 commit into
get-bb:mainfrom
robennals:bb/add-standard-keyboard-shortcuts-to-the-bb-thr_nttab8umdq

Conversation

@robennals

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

The integrated terminal never installed a key handler, so every key went through xterm.js's default translation. On macOS that translation sends nothing for Cmd+Left and Cmd+Right, and sends a plain delete for Cmd+Backspace, so the standard line-editing shortcuts did nothing useful. See #4759.

What changed

  • New key mapping in apps/app/src/components/thread/terminal/terminal-mac-editing-keys.ts. On macOS the terminal now sends the control characters shells already bind to line and word editing:

    Keys Sends Effect in the shell
    Cmd+Left Ctrl+A Start of line
    Cmd+Right Ctrl+E End of line
    Cmd+Backspace Ctrl+U Delete to start of line (zsh deletes the whole line)
    Cmd+Delete (forward delete) Ctrl+K Delete to end of line
    Option+Left / Option+Right Esc b / Esc f Back / forward one word
    Option+Delete (forward delete) Esc d Delete next word
  • Hooked up in ThreadTerminalView.tsx through xterm.js's attachCustomKeyEventHandler, only when the platform is macOS. Every other key, and every other platform, still goes through xterm.js unchanged.

  • No wire, CLI or doc changes.

Decisions

  • Option+arrow word movement is included. The issue's observed failures are the Cmd keys; Option+Left/Right are part of the same standard set and xterm.js's default sequence for them is not bound in shells by default. Alternative rejected: a Cmd-only change.
  • The shortcuts are fixed, not rebindable in Settings → Keyboard. Making them rebindable means adding them to the app command list, which is a larger change. This matches how VS Code ships them.
  • They apply everywhere in the terminal, including full-screen programs such as vim. VS Code does the same. Alternative rejected: disabling them while a full-screen program is running.
  • Cmd+K (Terminal has no clear command: Cmd+K does nothing, and neither keyboard settings nor a plugin can add it #3570) and copy/paste (Support copy-and-paste keyboard shortcuts in the integrated terminal #3341) are not addressed. They need different behaviour, though they can build on the key handler this adds.

How you verified

  • Tests: new cases in ThreadTerminalView.test.ts cover each mapped key, the key-up of a handled shortcut, and combinations that must be left to xterm.js. pnpm exec turbo run test --filter=@bb/app -- src/components/thread/terminal/ThreadTerminalView.test.ts reported Tests 44 passed (44).
  • Typecheck: pnpm exec turbo run typecheck --filter=@bb/app reported Tasks: 3 successful, 3 total.
  • Lint: pnpm exec turbo run lint --filter=@bb/app passed.
  • Not verified: the shortcuts have not been tried in the running desktop app.

Fixes #4759

AGENT GENERATED

🤖 Generated with Claude Code

On macOS the terminal now translates Command+Left/Right, Command+Backspace,
Command+Delete and Option+Left/Right/Delete into the control characters
shells use for line and word editing. xterm.js sends nothing for
Command+arrows and a plain delete for Command+Backspace, so these keys
previously did nothing useful.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator

This is an automated message. We have closed this pull request because it has been open for more than two weeks.

@SawyerHood SawyerHood closed this Oct 17, 2026
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.

Terminal ignores standard macOS line-editing shortcuts (Cmd+Left/Right, Cmd+Backspace, Option+Left/Right)

2 participants