Problem
Currently, the input field supports keyboard-based text selection via Shift+Arrow keys and other input_select_* keybindings, but there is no way to copy or cut the selected text using the keyboard. Users must resort to mouse selection to copy text to the clipboard, which breaks keyboard-centric workflows.
While mouse selection works well and automatically copies to clipboard via OSC52, power users who prefer keyboard navigation have no equivalent functionality.
Current Workarounds
- Use mouse to select text (automatically copied)
- Use
Ctrl+Y to copy console-level selections (but this doesn't work for textarea keyboard selections)
Proposed Solution
Add two new keybindings that work with keyboard-based text selection in the input field:
input_copy (default: Ctrl+Shift+C) - Copy selected text to clipboard
input_cut (default: Ctrl+Shift+X) - Cut selected text to clipboard (copy + delete)
Implementation Details
The implementation follows the established pattern of input_paste and input_clear:
-
Config Schema: Add keybind definitions to config.ts
-
Event Handlers: Add handlers in prompt/index.tsx that:
- Check for active selection using
input.hasSelection()
- Retrieve selected text using
input.getSelectedText()
- Copy to clipboard using existing
Clipboard.copy() utility
- For cut: delete selection using
input.deleteChar()
-
Key Technical Points:
- Uses TextareaRenderable's public API only
- Leverages existing cross-platform Clipboard utility
- Includes error handling with console logging
- Prevents default event handling when operations succeed
- No breaking changes (new optional keybindings with sensible defaults)
Benefits
- ✅ Enables fully keyboard-centric workflow
- ✅ Follows CUA (Common User Access) standard conventions
- ✅ Consistent with standard text editors (VS Code, Sublime, etc.)
- ✅ No breaking changes (purely additive)
- ✅ Cross-platform compatible (uses existing Clipboard utility)
- ✅ Works with all existing selection keybindings (
Shift+Arrow, Ctrl+Shift+Home, etc.)
Default Keybindings Rationale
Ctrl+Shift+C for copy: Standard terminal copy binding, avoids conflict with input_clear (Ctrl+C)
Ctrl+Shift+X for cut: Safe binding that doesn't conflict with leader key patterns
Both are easily customizable via the config file.
Testing Plan
- Select text using
Shift+Arrow keys
- Press
Ctrl+Shift+C and verify text is copied to clipboard
- Paste elsewhere and verify copied content
- Select text and press
Ctrl+Shift+X
- Verify text is copied to clipboard AND deleted from input
- Test with custom keybindings in config file
- Verify no conflicts with existing keybindings
Note: I am currently working on a pull request for this feature.
Problem
Currently, the input field supports keyboard-based text selection via
Shift+Arrowkeys and otherinput_select_*keybindings, but there is no way to copy or cut the selected text using the keyboard. Users must resort to mouse selection to copy text to the clipboard, which breaks keyboard-centric workflows.While mouse selection works well and automatically copies to clipboard via OSC52, power users who prefer keyboard navigation have no equivalent functionality.
Current Workarounds
Ctrl+Yto copy console-level selections (but this doesn't work for textarea keyboard selections)Proposed Solution
Add two new keybindings that work with keyboard-based text selection in the input field:
input_copy(default:Ctrl+Shift+C) - Copy selected text to clipboardinput_cut(default:Ctrl+Shift+X) - Cut selected text to clipboard (copy + delete)Implementation Details
The implementation follows the established pattern of
input_pasteandinput_clear:Config Schema: Add keybind definitions to
config.tsEvent Handlers: Add handlers in
prompt/index.tsxthat:input.hasSelection()input.getSelectedText()Clipboard.copy()utilityinput.deleteChar()Key Technical Points:
Benefits
Shift+Arrow,Ctrl+Shift+Home, etc.)Default Keybindings Rationale
Ctrl+Shift+Cfor copy: Standard terminal copy binding, avoids conflict withinput_clear(Ctrl+C)Ctrl+Shift+Xfor cut: Safe binding that doesn't conflict with leader key patternsBoth are easily customizable via the config file.
Testing Plan
Shift+ArrowkeysCtrl+Shift+Cand verify text is copied to clipboardCtrl+Shift+XNote: I am currently working on a pull request for this feature.