Skip to content

[Feature Request] Add config option to disable copy-on-select behavior #10490

Closed

Description

@cbrunnkvist

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

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

    @github-actions
    Contributor

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

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

  3. ariane-emory commented on Jan 25, 2026

    @ariane-emory
    Contributor

    Instead of making this a new setting in opencode.json and 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 the command_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 the kv.json file.

  4. ariane-emory commented on Jan 25, 2026

    @ariane-emory
    Contributor

    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.

  5. cbrunnkvist commented on Jan 26, 2026

    @cbrunnkvist
    Author

    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)

  6. tonglil commented on Jan 27, 2026

    @tonglil

    @ariane-emory the problem with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT is 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.

    Image

  7. ariane-emory commented on Jan 27, 2026

    @ariane-emory
    Contributor

    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.

  8. tonglil commented on Jan 27, 2026

    @tonglil

    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.

    Image

    As soon as you release the mouse, the selection disappears.

  9. cbrunnkvist commented on Jan 28, 2026

    @cbrunnkvist
    Author
  10. ariane-emory commented on Jan 28, 2026

    @ariane-emory
    Contributor

    @jhrudden I've got a fix that seemingly works correctly for:

    • iTerm2, ghostty, Kitty on MacOS.
    • The stock terminal on recent versions of Fedora and Ubuntu.

    Just waiting to hear back from a Windows user about whether the fix works for them there.

  11. ErcinDedeoglu commented on Feb 3, 2026

    @ErcinDedeoglu

    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:

    1. Intercepts mouse selection
    2. Clears the selection
    3. Shows "copied" (but OSC52 silently fails)
    4. Nothing in clipboard, selection gone

    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: false option would at least let us manually select + Cmd+C as a workaround.

  12. Obazzi commented on Mar 23, 2026

    @Obazzi

    In st I 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:

    echo "regular clipboard current" | xclip -selection clipboard
    

    To using this:

    echo "to selection clipboard" | xclip -selection primary
    

    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.

  13. ygerlach commented on Apr 27, 2026

    @ygerlach

    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?

  14. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  15. tidux commented on May 5, 2026

    @tidux

    I'm trying to use opencode on a remote host wrapped in mosh+tmux and this is extremely retarded behavior.

  16. lee-b commented on May 16, 2026

    @lee-b

    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

  17. disarticulate commented on May 29, 2026

    @disarticulate

    Does not work in any useful manner; disable it completely.

  18. tidux commented on Jun 5, 2026

    @tidux

    Update: https://github.com/zeroclaw-labs/zeroclaw v0.8.0 and its zerocode TUI have the behavior I need. I will no longer be using opencode as much.

  19. treasuretron commented on Jul 7, 2026

    @treasuretron

    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?

  20. akostadinov commented on Sep 1, 2026

    @akostadinov

    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.

  21. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    You can switch between manual / auto in tui settings

  22. Sylvain303 commented on Nov 4, 2026

    @Sylvain303

    29. You can switch between manual / auto in tui settings

    @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.

    Image

    Note for Linux xterm's user CTRL+C suffice here to make the 'Copied to Clipboard' (= break in terminal) not the common SHIFT+CTRL+C (copy in terminal)

    some ssh ticks could be useful

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