Skip to content

Clipboard copy not working over SSH + tmux in Ghostty #15907

Closed

Description

@Ayoola

Description

OpenCode's copy function shows "copied to clipboard" notification but doesn't actually update the system clipboard when running over SSH inside tmux.

Description

OpenCode's copy function shows "copied to clipboard" notification but doesn't actually update the system clipboard when running over SSH inside tmux.

Environment

  • Terminal: Ghostty on macOS
  • Remote: SSH into Linux workstation
  • Multiplexer: tmux with set -g set-clipboard on
  • OpenCode pane: right side of a tmux split

Steps to Reproduce

  1. SSH into a remote machine from Ghostty
  2. Start tmux with a horizontal split – shell on the left, OpenCode on the right
  3. Highlight/copy text from the OpenCode pane
  4. Attempt to paste with Cmd+V

Expected

Copied text appears in the macOS clipboard.

Actual

OpenCode shows "copied to clipboard" notification, but Cmd+V pastes the previous clipboard content. The clipboard is not updated.

Notes

  • Copying from the shell pane in the same tmux session works correctly – clipboard is updated and Cmd+V pastes the new content.
  • This suggests tmux and Ghostty OSC 52 passthrough are configured correctly, and the issue is specific to how OpenCode emits the OSC 52 sequence.

Plugins

N/A

OpenCode version

1.2.15

Steps to reproduce

  1. SSH into a remote machine from Ghostty
  2. Start tmux with a horizontal split – shell on the left, OpenCode on the right
  3. Highlight/copy text from the OpenCode pane
  4. Attempt to paste with Cmd+V

Screenshot and/or share link

No response

Operating System

MacOS 26.3

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 3, 2026
  2. github-actions commented on Mar 3, 2026

    @github-actions
    Contributor

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

    If your issue is covered by one of these, consider adding a comment there with your specific environment details (SSH + tmux + Ghostty) rather than a new issue.

  3. Ayoola commented on Mar 3, 2026

    @Ayoola
    Author

    This resolved my issue @thdxr:

    Ghostty: allow OSC52 clipboard access

    copy-on-select = clipboard
    clipboard-read = allow
    clipboard-write = allow
    
    

    tmux: allow OSC52 passthrough

    set -g allow-passthrough on

    Source: https://petar.dev/notes/copypaste-for-opencode-with-ghostty-and-tmux/

  4. vcastellm commented on Mar 18, 2026

    @vcastellm

    Thx @Ayoola that fixed the issue for me

  5. hqhq1025 commented on Apr 12, 2026

    @hqhq1025

    If you're on macOS, clipaste may help — it's a background daemon that normalizes the screenshot clipboard so image paste works in terminal AI tools. Also supports SSH remote paste.

    brew install hqhq1025/clipaste/clipaste
    brew services start clipaste

    For SSH remote: clipaste ssh-setup user@host

    GitHub: https://github.com/hqhq1025/clipaste

  6. bts-ericwooley commented on Apr 23, 2026

    @bts-ericwooley

    I'm not using ghostty, i'm using iterm2, ssh into linux, then running tmux. But i found this thread looking for answers to this and set -g allow-passthrough on was what I needed.

    ❯ cat ~/.tmux.conf
    # ==================================
    # == COMMON SETTINGS (for all OS) ==
    # ==================================
    # These settings will apply to both Linux and macOS
    
    set-option -g mouse on
    set-option -g set-clipboard on
    set -g allow-passthrough on
    
    # Enable OSC 52 clipboard (works for mouse copy, even over SSH)
    # This tells tmux to use the terminal's clipboard
    set -as terminal-overrides ',*:Ms=\E]52;%p1%s;%p2%s\a'
    
    # Pane navigation
    bind h select-pane -L    # left
    bind j select-pane -D    # down
    bind k select-pane -U    # up
    bind l select-pane -R    # right
    
    # Window navigation
    bind n previous-window
    bind m next-window
    
    
    # ====================================
    # == OS-SPECIFIC SETTINGS ==
    # ====================================
    
    # Change status bar to teal if on dev-box
    if-shell "[ $(hostname) = 'dev-box' ]" \
        "set -g status-bg colour36" \
        "set-option -g allow-passthrough on"
    
    # -----------------
    # --- macOS (Darwin) ---
    # -----------------
    if-shell "test $(uname) = 'Darwin'" " \
        bind-key -T copy-mode-vi v send-keys -X begin-selection; \
        bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy'; \
        bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'pbcopy' \; \
        bind p run 'pbpaste | tmux load-buffer - ; tmux paste-buffer' \
    "
    # ====================================
    # == PANE & WINDOW CREATION ==
    # ====================================
    
    # Split panes using current directory
    bind '"' split-window -v -c "#{pane_current_path}"
    bind % split-window -h -c "#{pane_current_path}"
    
    # Open new windows in the current directory
    bind c new-window -c "#{pane_current_path}"
    
    

    is my full tmux

  7. assigned and unassigned on Apr 26, 2026
  8. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. SOF3 commented on May 12, 2026

    @SOF3

    Does opencode even support tmux clipboard in the first place without using xclip? I want opencode to copy to the tmux clipboard without messing with the system clipboards

  10. pcfreak30 commented on May 14, 2026

    @pcfreak30

    This resolved my issue @thdxr:

    Ghostty: allow OSC52 clipboard access

    copy-on-select = clipboard
    clipboard-read = allow
    clipboard-write = allow
    

    tmux: allow OSC52 passthrough

    set -g allow-passthrough on

    Source: https://petar.dev/notes/copypaste-for-opencode-with-ghostty-and-tmux/

    This solved for me as well. have to use ghosty and tmux for the full terminal wire protocol.

  11. joelceo commented on May 20, 2026

    @joelceo

    Solution found: install xclip

    sudo apt install xclip
    My environment:

    • Ubuntu 26.04 + Ptyxis + Wayland
    • OpenCode 1.15.5
    • No multiplexers (tmux/zellij)

    Why it works: OpenCode seems to use xclip as a fallback for copying to the clipboard when OSC52 fails (which happens in certain Linux terminals with Wayland).
    Before this, auto-copy-on-select showed "Copied to clipboard" but never reached the clipboard. After installing xclip, it works perfectly.
    Note: the solution is simple and doesn't require changing terminals or disabling Wayland. Hope this helps other users with the same issue.

  12. finnvyrn commented on Jun 26, 2026

    @finnvyrn

    I also met this issue with Hyprland and macOS

  13. vcastellm commented on Jun 30, 2026

    @vcastellm

    This worked with these settings at this point #15907 (comment) then it stopped working this is Ghostty related.

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