feat: osc 5522 clipboard#4035
Open
UnnaturalTwilight wants to merge 5 commits into
Open
Conversation
Author
|
Due to the significant discrepancy between Kitty's actual behavior and what is described at https://rockorager.dev/misc/bracketed-paste-mime/ I wrote up a Gist describing how the spec is actually implemented in Kitty. |
sxyazi
requested changes
Jun 10, 2026
sxyazi
requested changes
Jun 11, 2026
sxyazi
requested changes
Jun 11, 2026
sxyazi
requested changes
Jun 11, 2026
sxyazi
requested changes
Jun 11, 2026
sxyazi
requested changes
Jun 11, 2026
6ecdd43 to
ba8ab7e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale of this PR
Adds support for using OSC 5522 (Kitty Clipboard Extension) to read and write all mime types from the system clipboard.
The main protocol can be found here: https://sw.kovidgoyal.net/kitty/clipboard/#copying-all-data-types-to-the-clipboard
The specification for paste events can be found here: https://rockorager.dev/misc/bracketed-paste-mime/
In cases where Kitty's implementation differs from the above specifications I have followed Kitty's implementation.
This pr implements support for copying and pasting
text/uri-listas well astext/plain. The paste events have been exposed to lua similarly to drag and drop allowing supporting more formats easily. I have left the existing clipboard functions as is soya.clipboard()and similar continue to use external clipboard tools. In the case of the copy keybindings support for OSC 5522 is detected and OSC 5522 is used if available, otherwise the original clipboard commands are used.For now I have left the same 1MB size limit as the drag and drop however this will need to be revisited to support directly pasting files such as images from the clipboard.
I have tested this with Kitty 0.47.1
Checklist