Description
OC implements "XTerm / GPM"-style copy-on-select
Selecting text with the mouse automatically copies it to the clipboard when the mouse button is released. As far as I can find, there is no way to disable this behavior.
I'd like to be able to turn off copy-on-select via opencode.json config because frankly it interferes with the way I read and mark text on screen, in particular when screen sharing or pair coding. And I really don't appreciate accidental clipboard overwrites when scrolling/selecting to read text.
I understand that the TUI is mouse-aware, and I am aware that in e.g. Ghostty's config I can set mouse-shift-capture = never to make shift+click always selects text, without notifying the app, but I'd still like to prevent OC from bungling my current clipboard contents.
Proposed Solution
I guess a tui.copy_on_select config option would suffice. Keep its default as true to avoid surprising existing users.
{
"tui": {
"copy_on_select": false
}
}Current Behavior
Mouse selection → automatic clipboard copy
Expected Behavior (when disabled)
Allows users to select text visually without side effects
Activity
github-actions commentedon Jan 25, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
ariane-emory commentedon Jan 25, 2026
Instead of making this a new setting in
opencode.jsonand changing the shape of the config schema, I think that a better implementation would be to control it using a new menu item in the System category of thecommand_list, appearing as either "Disable copy-on-select" or "Enable-copy-on-select" (dependant upon it's current state) whose current state is persisted to thekv.jsonfile.ariane-emory commentedon Jan 25, 2026
Upon review, a OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag was added in the merged PR #4996. To me, this flag seems entirely adequate to resolve the issue, I'll leave this be.
cbrunnkvist commentedon Jan 26, 2026
Ah, thanks @ariane-emory, I failed to find that despite fuzzy searching for "copy on select" ...
I can confirm that
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 opencode, while still not retaining the text-selection highlight at least prevents it from clobbering the clipboard. I'll be using that for now; thanks again.(I thought I kind of knew terminal programming, but I realize I actually have no idea about what control codes or -modes are used by mouse extensions)
tonglil commentedon Jan 27, 2026
@ariane-emory the problem with
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECTis that it no longer lets me select text in the terminal (and keep it selected). It's acting like "DISABLE_SELECT" all together.I want to be able to select some text in the terminal, and optionally copy it if I want to with cmd+c.
ariane-emory commentedon Jan 27, 2026
That's interesting that might have something to do with which terminal you're running it in? I'm afraid I'm not sure if there's another way to disable the copy on select behaviour, sorry.
tonglil commentedon Jan 27, 2026
I'm using iterm2.
You can see the select behavior works as expected in other apps.
Here's another capture that demonstrates selection working for claude code and not in opencode, this time in the mac's default terminal.
As soon as you release the mouse, the selection disappears.
cbrunnkvist commentedon Jan 28, 2026
ariane-emory commentedon Jan 28, 2026
@jhrudden I've got a fix that seemingly works correctly for:
Just waiting to hear back from a Windows user about whether the fix works for them there.
ErcinDedeoglu commentedon Feb 3, 2026
This feature request is now critical for VS Code Remote SSH users.
With v1.1.49's OSC52 clipboard (which doesn't work in VS Code Remote SSH), copy-on-select:
There's literally no way to copy text from opencode in VS Code Remote SSH without this config option.
See #11909 for the full context. The
tui.copy_on_select: falseoption would at least let us manually select + Cmd+C as a workaround.Obazzi commentedon Mar 23, 2026
In
stI can hold shift to select text using the terminal when inside of a TUI like OpenCode or LazyGit that disable the terminal selection (mouse reporting clicks mode), and it puts the text in the PRIMARY selection and stays selected, and if I hit the copy keybind (Ctrl + Shift + C for me) while selected, it copies the selected text to the CLIPBOARD selection. IDK about other terminals.But personally this is not optimal because OpenCode dose the line unwrapping, it copy the actual lines not what is on screen, it just works better then the terminal's selection. But in the Linux/UNIX/X11 world if you don't copy to PRIMARY selection on select, you are bringing a Windowsism to Linux. OpenCode is literally the only program on my entire computer that use CLIPBOARD instead of the selection upon selection. It is starting to confuse my muscle memory as I go between everything else and OpenCode as I now middle mouse click (paste selection) when I should have Ctrl + Shift + V (paste clipboard) or vice versa. IMO, adding a toggle to use PRIMARY selection instead of CLIPBOARD would be the correct choice. I see disabling the copy on selection and witch selection as 2 separate options.
The change is just going from this:
To using this:
in 2 spots and then a similar thing for the xsel in the code packages/opencode/src/cli/cmd/tui/util/clipboard.ts or let the user choose at runtime somehow.
ygerlach commentedon Apr 27, 2026
I often use opencode inside a container (because i don't trust the agents).
The "auto-copy-to-clipboard" keeps me from copying the code at all, because it pastes it inside the containers clipboard, if such thing exist. Even with the
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1. It keeps the selection, but i still cant copy (neither with ctrl+c(+shift), or right click).But when i set the flag the selection stays until i right click. So there is a change.
Is there any way to disable any mouse interaction completely, so one can just use the terminal emulators copy function?
tidux commentedon May 5, 2026
I'm trying to use opencode on a remote host wrapped in mosh+tmux and this is extremely retarded behavior.
lee-b commentedon May 16, 2026
Yes please. Mouse selection/paste is really broken right now. With most X terminals, we can override with shift-rightmouse or similar, to at least get paste from clipboard support, but the copy on selection disables any opportunity to copy to the clipboard :/
Also, OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 currently allows selection, but effectively only delays the prior behavior: right-clicking, even with shift-rightclick to get the terminal menu for copying (and other actions) results in the prior behaviour: a "copied to clipboard" message from opencode (which seems to be untrue) appears, and the selection is cleared, before one can use the terminal menu to copy/paste (copy is then ghosted in the terminal menu, because nothing is selected at that point).
I'm just going to leave this here: a demo of working copy and paste: FROM 1968 ;) https://www.youtube.com/watch?v=B6rKUf9DWRI
disarticulate commentedon May 29, 2026
Does not work in any useful manner; disable it completely.
tidux commentedon Jun 5, 2026
Update: https://github.com/zeroclaw-labs/zeroclaw v0.8.0 and its
zerocodeTUI have the behavior I need. I will no longer be using opencode as much.treasuretron commentedon Jul 7, 2026
yeah this breaks things when running opencode on another machine over ssh. I cannot copy text! This is driving me nuts and totally breaks things. How is anyone able to move forward without the ability to copy text out of opencode?
akostadinov commentedon Sep 1, 2026
Using konsole I don't see copy/paste with middle button working. Would be much easier if it worked out of the box instead of requiring hold shift.
neriousy commentedon Oct 1, 2026
You can switch between manual / auto in tui settings
Sylvain303 commentedon Nov 4, 2026
@neriousy seem to works, great. 👍🏻
Could you point to some code + doc explaining how it works?
Actually it let the user to configure the copy triggering, but still not where it's copied
Ran on a sshed remote computer.
Note for Linux xterm's user
CTRL+Csuffice here to make the 'Copied to Clipboard' (= break in terminal) not the commonSHIFT+CTRL+C(copy in terminal)some ssh ticks could be useful