{"slug": "preventing-accidental-opencode-exits-with-ctrl-c", "title": "Preventing Accidental OpenCode Exits with Ctrl+C", "summary": "A developer has documented a configuration workaround for OpenCode that prevents accidental session loss when users press Ctrl+C out of terminal habit. By remapping the app_exit keybinding in the OpenCode configuration file to Ctrl+D or a leader-based shortcut, the interrupt command no longer closes the entire application. The change separates interrupting a running process from exiting the AI coding agent, preserving long sessions with valuable context.", "body_md": "OpenCode is powerful, but one default behavior kept getting in my way: pressing `Ctrl + C` could close the application itself.\n\nIf you spend a lot of time in terminals, `Ctrl + C` is muscle memory. You press it to interrupt a command, stop a long-running process, or simply because your hands move before you think.\n\nLosing the whole OpenCode session because of that is frustrating.\n\nThe fix is simple: move the application exit action to a different keybinding.\n\nOpen your OpenCode configuration file and customize the keybindings.\n\nFor example:\n\n```\n{\n  \"keybinds\": {\n    \"app_exit\": \"ctrl+d,<leader>q\"\n  }\n}\n```\n\nWith this configuration, `Ctrl + C` is no longer the application-exit shortcut.\n\nYou can then use `Ctrl + D` or the leader-based shortcut to exit intentionally.\n\nAI coding agents often stay open for long sessions with valuable context.\n\nA keybinding that is common for interruption in terminal workflows should not unexpectedly destroy that session.\n\nSeparating \"interrupt what is happening\" from \"close the entire application\" makes the interface much harder to use incorrectly.\n\nThis is a tiny configuration change, but it removed one of the most annoying sources of accidental session loss for me.\n\nIf you use OpenCode inside a terminal and frequently hit `Ctrl + C` out of habit, remapping `app_exit` is worth doing early.", "url": "https://wpnews.pro/news/preventing-accidental-opencode-exits-with-ctrl-c", "canonical_source": "https://dev.to/loach2009/preventing-accidental-opencode-exits-with-ctrlc-39dh", "published_at": "2026-09-10 11:50:23+00:00", "updated_at": "2026-09-10 11:58:12.094549+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["OpenCode"], "alternates": {"html": "https://wpnews.pro/news/preventing-accidental-opencode-exits-with-ctrl-c", "markdown": "https://wpnews.pro/news/preventing-accidental-opencode-exits-with-ctrl-c.md", "text": "https://wpnews.pro/news/preventing-accidental-opencode-exits-with-ctrl-c.txt", "jsonld": "https://wpnews.pro/news/preventing-accidental-opencode-exits-with-ctrl-c.jsonld"}}