-
Shift+Enter newline for TUIs in Windows Terminal
Problem: Windows Terminal sends the same byte for Enter and Shift+Enter, so apps like OpenCode can't tell them apart. Shift+Enter submits instead of inserting a line.
Fix: Let Windows Terminal send a real newline byte when Shift+Enter is pressed.
Manual setup
File:
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.jsonAdd to the
actionsarray:{ "command": { "action": "sendInput", "input": "\n" }, "id": "User.sendInput.shiftEnter" }Add to the
keybindingsarray:{ "id": "User.sendInput.shiftEnter", "keys": "shift+enter" }Save the file. Windows Terminal reloads on its own; if it lags, open and close its Settings (
Ctrl+,). Test: press Shift+Enter in the prompt, you should get a new line.One-shot PowerShell
$p = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" $j = Get-Content $p -Raw | ConvertFrom-Json $id = 'User.sendInput.shiftEnter' if (-not ($j.actions | Where-Object { $_.id -eq $id })) { $j.actions += [pscustomobject]@{ command = [pscustomobject]@{ action = 'sendInput'; input = [string][char]10 } id = $id } } $keys = @('shift+enter') # add 'ctrl+enter' here to enable that key too foreach ($k in $keys) { if (-not ($j.keybindings | Where-Object { $_.id -eq $id -and $_.keys -eq $k })) { $j.keybindings += [pscustomobject]@{ id = $id; keys = $k } } } [System.IO.File]::WriteAllText($p, ($j | ConvertTo-Json -Depth 20), (New-Object System.Text.UTF8Encoding($false)))Notes
"\n"is a single newline character (byte 10), the same one Ctrl+J sends.- Ctrl+J inserts a newline in OpenCode with zero setup; it's the fastest fallback.
- Ctrl+Enter can share the same action: add
{ "id": "User.sendInput.shiftEnter", "keys": "ctrl+enter" }. - To undo: remove the added entries from the file and save.
- The PowerShell version rewrites the file in normalized formatting; the manual edit preserves your existing formatting.
- Non-Store installs keep settings at
%LOCALAPPDATA%\Microsoft\Windows Terminal\settings.json.
Please register or sign in to comment