BUILD / copy-clipboard-over-ssh-with-grok-wrap

Build

Copy from a remote shell into your local clipboard with grok wrap

Copy from a remote shell into your local clipboard with grok wrap

Grok Build writes to the native OS clipboard, to the tmux paste buffer inside tmux, and emits OSC 52 for remote cases (SSH, containers, Linux). Apple Terminal ignores OSC 52 entirely, so copies over SSH never reach your local clipboard. Official: Terminal Support.

Use grok wrap

grok wrap runs a command in a local PTY that intercepts OSC 52 and writes to your machine’s clipboard. It is marked experimental in the docs.

grok wrap ssh user@host
grok wrap docker exec -it container bash
grok wrap kubectl exec -it pod -- bash

Inside the wrapped session, Grok (or anything emitting OSC 52) can copy to the clipboard on the machine where you launched grok wrap.

Other clipboard fixes

Situation Fix
iTerm2 ignores OSC 52 Settings → General → Selection → enable “Applications in terminal may access clipboard”
Inside tmux set -g set-clipboard on and set -g allow-passthrough on in ~/.tmux.conf, then tmux source-file ~/.tmux.conf
Diagnose what Grok detected Run /terminal-setup (aliases /terminal-check, /terminal-info) inside the TUI

Related

Pitfalls

  • Expecting bare ssh under Apple Terminal to deliver OSC 52 copies — wrap the remote command instead.
  • Forgetting grok wrap is experimental; keep a fallback (paste buffer, file, or local terminal with OSC 52 enabled).