From e630d680ddfae0ed6e51d54e63c6765b277174a3 Mon Sep 17 00:00:00 2001 From: Nathan Thomas Date: Fri, 31 Oct 2025 14:27:41 -0700 Subject: [PATCH] feat: allow ctrl+d to exit the app (#3636) --- .../src/cli/cmd/tui/component/prompt/index.tsx | 11 +++++++++++ packages/opencode/src/config/config.ts | 3 ++- packages/sdk/js/src/gen/types.gen.ts | 4 ++++ packages/web/src/content/docs/keybinds.mdx | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 20015c30..c5a195f3 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -530,6 +530,17 @@ export function Prompt(props: PromptProps) { setStore("extmarkToPartIndex", new Map()) return } + if (keybind.match("input_forward_delete", e) && store.prompt.input !== "") { + const cursorOffset = input.cursorOffset + if (cursorOffset < input.plainText.length) { + const text = input.plainText + const newText = text.slice(0, cursorOffset) + text.slice(cursorOffset + 1) + input.setText(newText) + input.cursorOffset = cursorOffset + } + e.preventDefault() + return + } if (keybind.match("app_exit", e)) { await exit() return diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index fec94960..ac1165ea 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -385,7 +385,7 @@ export namespace Config { .optional() .default("ctrl+x") .describe("Leader key for keybind combinations"), - app_exit: z.string().optional().default("ctrl+c,q").describe("Exit the application"), + app_exit: z.string().optional().default("ctrl+c,ctrl+d,q").describe("Exit the application"), editor_open: z.string().optional().default("e").describe("Open external editor"), theme_list: z.string().optional().default("t").describe("List available themes"), sidebar_toggle: z.string().optional().default("b").describe("Toggle sidebar"), @@ -454,6 +454,7 @@ export namespace Config { agent_cycle: z.string().optional().default("tab").describe("Next agent"), agent_cycle_reverse: z.string().optional().default("shift+tab").describe("Previous agent"), input_clear: z.string().optional().default("ctrl+c").describe("Clear input field"), + input_forward_delete: z.string().optional().default("ctrl+d").describe("Forward delete"), input_paste: z.string().optional().default("ctrl+v").describe("Paste from clipboard"), input_submit: z.string().optional().default("enter").describe("Submit input"), input_newline: z diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index e4ee9db3..c4339c31 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -134,6 +134,10 @@ export type KeybindsConfig = { * Clear input field */ input_clear?: string + /** + * Forward delete characters in input field + */ + input_forward_delete?: string /** * Paste from clipboard */ diff --git a/packages/web/src/content/docs/keybinds.mdx b/packages/web/src/content/docs/keybinds.mdx index dc47166b..884dad03 100644 --- a/packages/web/src/content/docs/keybinds.mdx +++ b/packages/web/src/content/docs/keybinds.mdx @@ -11,7 +11,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf "keybinds": { "leader": "ctrl+x", "app_help": "h", - "app_exit": "ctrl+c,q", + "app_exit": "ctrl+c,ctrl+d,q", "editor_open": "e", "theme_list": "t", "project_init": "i", @@ -42,6 +42,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf "agent_cycle": "tab", "agent_cycle_reverse": "shift+tab", "input_clear": "ctrl+c", + "input_forward_delete": "ctrl+d", "input_paste": "ctrl+v", "input_submit": "enter", "input_newline": "shift+enter,ctrl+j"