Query or Change Clipboard Data (OSC 52)

Query or change data on clipboards.

  1. 0x1B
    ESC
  2. 0x5D
    ]
  3. 0x35 0x32
    52
  4. 0x3B
    ;
  5. ____
    t
  6. 0x3B
    ;
  7. ____
    d
  8. 0x1B
    ESC
  9. 0x5C
    \

Query or change data on clipboards specified by t based on the value of d.

t is a list of zero or more characters that each correspond to a different type of clipboard on the system. The meaning of each character in t as defined by xterm is as follows:

tType
cStandard clipboard
pPrimary clipboard
qSecondary clipboard
sSelection clipboard
07Cut-buffer 07

Note

Ghostty only recognizes c, p, and s as valid values in t. Other types are treated as aliases for c. When t is omitted, Ghostty defaults to querying or modifying the primary clipboard (equivalent to c).

Warning

Ghostty currently only allows specifying one clipboard per sequence. This is a limitation on our end and may be fixed in the future.

When d is the single character ?, the terminal will reply with another OSC 52 sequence with the data found from the first clipboard listed in t that contains the requested data.

Otherwise, d is expected to be a Base64-encoded string that contains the new data for all clipboards listed in t.

If d is neither a valid Base64-encoded string or the character ?, all clipboards listed in t are cleared.