BUILD / wrap-remote-commands-with-grok-for-clipboard

Build

Wrap remote commands with grok wrap for clipboard

Wrap remote commands with grok wrap for clipboard

Copy from a remote shell (SSH, docker exec, kubectl exec) often fails because OSC 52 never reaches your local clipboard. Apple Terminal ignores OSC 52 entirely. Official fix: run the remote command through grok wrap, which starts a local PTY that intercepts OSC 52 and writes to your OS clipboard. Docs: Terminal Support, CLI Reference.

Basic usage

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

Inside that wrapped session, run grok (or any tool that emits OSC 52). Copies that would have been stuck on the remote host should land on the local clipboard. The feature is marked experimental on the terminal-support page.

When wrap is the right tool

Situation Prefer
Apple Terminal + SSH grok wrap ssh …
iTerm2 ignoring OSC 52 Enable Settings → General → Selection → “Applications in terminal may access clipboard”, or wrap
tmux over SSH Also set set -g set-clipboard on and allow-passthrough in ~/.tmux.conf, then wrap if still stuck
Local-only clipboard bugs Fix terminal settings first — see Fix Grok Build terminal clipboard and keys

Diagnose before wrapping

Inside an interactive Grok session:

/terminal-setup

Aliases: /terminal-check, /terminal-info. That report shows detected terminal, clipboard routes, and suggested fixes. Keyboard chords that differ by terminal are listed on Keyboard Shortcuts.

Pitfalls

  • Wrap is for clipboard passthrough, not a substitute for grok login --device-auth on headless hosts.
  • Nested multiplexers (tmux inside Zellij, etc.) can still steal chords; unlock or reconfigure the outer layer first.
  • If colors look wrong after wrap, set COLORTERM=truecolor and confirm the inner terminal still has truecolor.