Skip to content

[UX] Ctrl+C should not exit OpenCode - conflicts with universal copy shortcut #7957

Closed as duplicate

Description

@SYRS-AI

Description

Pressing Ctrl+C in OpenCode immediately exits the application. This is extremely frustrating because Ctrl+C is the universal copy shortcut on Windows (and commonly used on Linux too).

Users frequently press Ctrl+C out of habit when trying to copy text, and accidentally terminate their entire session - losing context and conversation history.

The Problem

Shortcut User Expectation OpenCode Behavior
Ctrl+C Copy selected text Exits application

This happens constantly during normal usage:

  • Copying error messages to search online
  • Copying code snippets from AI responses
  • Copying file paths or commands
  • General muscle memory from every other application

Expected Behavior

Option 1 (Recommended): Require double Ctrl+C or Ctrl+C twice within 1-2 seconds to exit

  • First Ctrl+C: Show message "Press Ctrl+C again to exit"
  • Second Ctrl+C: Actually exit

Option 2: Use a different exit shortcut

  • Ctrl+D (common in Unix terminals for EOF/exit)
  • Ctrl+Q (quit)
  • /exit or /quit command only

Option 3: Make Ctrl+C cancel current operation only (like Claude Code)

  • If AI is generating: Cancel generation
  • If idle: Do nothing or show exit hint
  • Never exit immediately on single Ctrl+C

Comparison with Other Tools

Tool Ctrl+C Behavior
Claude Code Cancels current operation, does NOT exit
Cursor Copy (normal IDE behavior)
VS Code Copy
Most CLI tools Interrupt current command, not exit shell

Environment

  • OS: Windows 11 (also affects Linux users)
  • Terminal: Windows Terminal, PowerShell, Git Bash

Related Issues

This deserves a dedicated issue due to its significant impact on user experience. Accidental exits cause real productivity loss.

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 12, 2026
  2. github-actions commented on Jan 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

    Feel free to ignore if none of these address your specific case.

  3. carljuneau commented on Jan 15, 2026

    @carljuneau

    Same here. I press Ctrl+C out of habit and get kicked out 4-5x a day. New user.

  4. stefanoallima commented on Jan 15, 2026

    @stefanoallima

    same the experience to copy text is very cumbersome

  5. HustCoderHu commented on Jan 25, 2026

    @HustCoderHu

    Same here. If ctrl+d exits, why have ctrl+c too? Plus, ctrl+c is already bound to the 'clear input' function.

  6. shrwnsan commented on Jan 30, 2026

    @shrwnsan

    Workaround till its not default, set the following in opencode.json

    "keybinds": {
      "app_exit": "ctrl+d,<leader>q"
    }
    

    Simply removes ctrl+c from default. HTH

  7. added a commit that references this issue on Jan 30, 2026
    a4df59d
  8. mcheiyue commented on Feb 4, 2026

    @mcheiyue

    相同问题确认 (Windows 11 + PowerShell)

    环境:

    • 操作系统: Windows 11
    • 终端: Windows Terminal + PowerShell
    • OpenCode 版本: 最新版

    问题描述:
    在 Windows Terminal 中使用 OpenCode TUI 时,习惯性使用 复制内容,但每次都会导致 TUI 意外退出。这个操作习惯在 Windows 生态中非常根深蒂固,每天误触多次严重影响使用体验。

    已尝试的解决方案:

    1. ✗ 修改 配置 - 无效(Ctrl+C 在到达 keybinds 处理器之前就被系统捕获)
    2. ✗ 修改 配置 - 无效(这只控制消息中断,不控制程序退出)
    3. ✗ 在 Node.js 包装层拦截 SIGINT - 无效(Windows 控制台直接广播信号给子进程)

    根本原因:
    根据我的调查,OpenCode 使用预编译的 二进制文件,Windows 控制台会直接将 (SIGINT) 广播给所有前台进程,配置文件和包装脚本层面都无法拦截。

    临时 Workaround:
    目前唯一有效的方案是使用 AutoHotkey 在系统级拦截 Ctrl+C:

    #Requires AutoHotkey v2.0
    
    IsOpenCodeRunning() {
        if ProcessExist("opencode.exe")
            return true
        return false
    }
    
    #HotIf IsOpenCodeRunning()
    ^c::
    {
        ToolTip("Ctrl+C 已禁用 (使用 Ctrl+Q 或 Ctrl+D 退出)")
        SetTimer () => ToolTip(), -2000
        return
    }
    #HotIf

    请求:
    希望能够在配置文件中添加选项彻底禁用 Ctrl+C 退出行为,例如:

    {
      "tui": {
        "disableCtrlCExit": true
      }
    }

    这个问题在 Windows 用户中非常普遍(参见 #2999, #10538),强烈建议作为高优先级 UX 改进项。

    感谢团队的辛勤工作!期待官方解决方案 🙏

  9. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Collaborator

    Thanks for the detailed context on the Windows-specific behavior. You're right that on Windows, Ctrl+C can be intercepted at the console level before reaching the TUI keybind handlers in some scenarios.

    Good news: There are already PRs open to address this:

    Your workaround in the keybinds config does work for most cases:

    "keybinds": {
      "app_exit": "ctrl+d,<leader>q"
    }

    The AutoHotkey approach you shared is clever for cases where the signal gets caught at the OS/Bun level before OpenCode can handle it. That said, the config workaround should work for the majority of Windows users.

    This issue is being tracked alongside #9041 (detailed implementation spec) and #2999. Will leave this open for visibility until one of the PRs lands.

  10. lightcomc commented on Feb 6, 2026

    @lightcomc

    same here

  11. added a commit that references this issue on Mar 1, 2026
    97c5dbb
  12. tagliala commented on Mar 19, 2026

    @tagliala

    Thanks for the detailed context on the Windows-specific behavior. You're right that on Windows, Ctrl+C can be intercepted at the console level before reaching the TUI keybind handlers in some scenarios.

    Hello, I do not have Windows, copy on mac is CMD + C, but I did accidentally press CTRL+C with the side of my finger because CTRL + X is the gateway to several other features, like subagent list.

    Removing CTRL+C as an immediate termination, at least when an action is running, would be a better default. For the moment of course I've edited tui.json

  13. G10h4ck commented on Mar 27, 2026

    @G10h4ck

    This is happening also on Linux and even with Ctrl+Shift+c which is Konsole shortcut for copy action (and many other terminals), disabling Ctrl+c keybinding in tui.json won't help. Terribly annoying :-(

    $ opencode --version
    1.2.6
    
    $ cat  ~/.config/opencode/tui.json 
    {
      "$schema": "https://opencode.ai/tui.json",
      "keybinds": {
        "app_exit": "<leader>q",
        "input_clear": "none"
      }
    }
    
  14. Konjac-XZ commented on Apr 30, 2026

    @Konjac-XZ

    Is anyone else still paying attention to this issue?

    In my opinion (I use SSH to access OpenCode on a remote host), allowing users to clear the input buffer with Ctrl+C when there is content, but having Ctrl+C directly exit the program while a task is being processed, is fundamentally inconsistent.

  15. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  16. Marcin-Kozyra commented on May 17, 2026

    @Marcin-Kozyra

    same....

  17. shiningbridge commented on Jun 1, 2026

    @shiningbridge

    Old version the keybinds can be put in the opencode.json file. ~/.config/opencode/opencode.json
    newer release try put into tui.json. ~/.config/opencode/tui.json

  18. trek-e commented on Jun 22, 2026

    @trek-e

    should at least be an are you sure with a way to turn that off its that is what you really want. mid run closed out and lost everything. its a 'stop' command most everywhere else where ctrl-d is the logout in most posix cli's

  19. kingtom2016 commented on Aug 10, 2026

    @kingtom2016

    same the experience to copy text is very cumbersome, Hope like claude code, double Ctrl + C to confirm to quit.

  20. osimarr commented on Aug 16, 2026

    @osimarr

    Please, do the option 1:
    Option 1 (Recommended): Require double Ctrl+C or Ctrl+C twice within 1-2 seconds to exit

    First Ctrl+C: Show message "Press Ctrl+C again to exit"
    Second Ctrl+C: Actually exit

  21. erfanium commented on Aug 28, 2026

    @erfanium

    wrote a small TUI plugin that does the double Ctrl+C thing (first press warns, second exits). Works on Linux/macOS, tested on 1.18.25: gist link:

    https://gist.github.com/erfanium/bf00644447d82e53691db4af29428253

  22. alextutor commented on Sep 4, 2026

    @alextutor

    https://www.unidadvirtual.com/opencode-cli-deseo-anular-la-combinacion-de-teclas-crl-c

    Solucion:

    Crear el archivo tui.json con app_exit deshabilitado:

    Podemos crearlo en forma global o solo para el proyecto:

    Opción A) Forma Global > Archivo: C:\Users\tu_usuario.config\opencode\tui.json

    Si deseas puedes usar el atajo para encontrar la carpeta global opencode , presionas las teclas Windows+R (abre el formulario ejecutar) y alli digitas %USERPROFILE%/.config/opencode/ , se te abrira la carpeta global opencode y creas el archivo tui.json

    Opción B) En el Proyecto > ./tui.json , El archivo lo creamos en la raiz del Proyecto.

    Contenido del archivo tui.json

    {
    "$schema": "https://opencode.ai/tui.json",
    "keybinds": {
    "app_exit": "none"
    }
    }
    Esto deshabilita Ctrl+C como atajo para salir. El valor "none" anula la combinación por defecto (ctrl+c, ctrl+d, q).

    Después de crear el archivo, reiniciar opencode para que los cambios tomen efecto.

  23. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #2999, which tracks Ctrl+C exiting OpenCode. Please add any details and 👍 there.

    In OpenCode v2 you can already change this by remapping or disabling the app.exit keybind (set it to "none") in tui.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions