^[control-codes
live in libghostty-vt

Operating system commands

OSC 72 Drag and Drop

View as Markdown

Let a program in the terminal accept dropped files and text, and start drags of its own: kitty's drag and drop protocol.

OSC 72 ; metadata ; payload ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51
Specification
The Drag and Drop protocol, kitty documentation

OSC 72 ; metadata ; payload ST lets a program in the terminal take part in drag and drop as a graphical program would: accept files or text dropped on it, by MIME type, and start drags of its own. Its definition is kitty’s Drag and Drop protocol. The metadata is key=value pairs separated by :, the t key says which message it is, and a payload over 4096 bytes is sent in chunks marked m=1. Some of the messages:

SequenceDoes
OSC 72 ; t=a ; types STaccept drops of these MIME types, a space-separated list
OSC 72 ; t=A STstop accepting drops
OSC 72 ; t=q STask whether the terminal has the protocol

A terminal that has it answers t=q with OSC 72 ; t=q ; payload ST, where the payload lists optional parts it supports, empty for now, and echoes an i= key if the question had one; a program sends the question and then DA, and takes an answer to DA alone as a no.

A default xterm does not have it and ignores it (the OSC numbers it knows). The cases follow xterm. libghostty-vt implements the protocol, passing drags and drops to its host through the drag_and_drop callback, and answers t=q itself, so that case is a known difference. It answers only a bare t=q, though: a question with i= goes unanswered, which kitty’s document says should be answered with the i echoed.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984NoOSC is not among the controls it recognizes (§4.2)
VT510manual, 1st ed., 1993Noignores an OSC string (chapter 4)
xtermpatch 412, xterm-411aNo
libghostty-vt0f171f6Partlypasses drags and drops to the host; OSC72-1: answers a bare t=q, but not one with i=
Konsole26.11.70, a24c3d71No
kitty0.49.2, its documentationYesDrag and Drop protocol
ConEmubuild 230724, its documentationNonot in ConEmu’s list, ANSI escape codes

Validation

OSC72-1: The question is not answered

\e]72;t=q\e\\
|______|
reply none

OSC72-2: Accepting drops changes nothing on screen

A
\e]72;t=a;dGV4dC9wbGFpbg==\e\\  # text/plain
B
|AB____|
cursor 1,3
reply none
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.