Skip to content

Commit d47a80c

Browse files
committed
Document the escape code format for the file transmission protocol
1 parent 5f4e326 commit d47a80c

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

docs/file-transfer-protocol.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,62 @@ creating links, etc. If any errors occur it responds with an error message,
108108
such as::
109109

110110
← action=status id=someid status=Some error occurred
111+
112+
113+
Encoding of transfer commands as escape codes
114+
------------------------------------------------
115+
116+
Transfer commands are encoded as OSC escape codes of the form::
117+
118+
<OSC> 5113 ; key=value ; key=value ... <ST>
119+
120+
Here ``OSC`` is the bytes ``0x1b 0x5d`` and ``ST`` is the bytes
121+
``0x1b 0x5c``. Keys are words containing only the characters ``[a-zA-Z0-9_]``
122+
and ``value`` is arbitrary data, whose encoding is dependent on the value of
123+
``key``. Unknown keys **must** be ignored when decoding a command.
124+
The number ``5113`` is a constant and is unused by any known OSC codes. It is
125+
the numeralization of the word ``file``.
126+
127+
128+
.. table:: The keys and value types for this protocol
129+
:align: left
130+
131+
================= ======== ============== =======================================================================
132+
Key Key name Value type Notes
133+
================= ======== ============== =======================================================================
134+
action ac Enum send, file, data, end_data, receive, cancel, status, finish
135+
compression zip Enum none, zlib
136+
file_type ft Enum regular, directory, symlink, link
137+
transmission_type tt Enum simple, rsync
138+
id id safe_string A unique-ish value, to avoid collisions
139+
file_id fid safe_string Must be unique per file in a session
140+
bypass pw safe_string hash of the bypass password and the session id
141+
quiet q integer 0 - verbose, 1 - only errors, 2 - totally silent
142+
mtime mod integer the modification time of file in nanoseconds since the UNIX epoch
143+
permissions prm integer the UNIX file permissions bits
144+
size sz integer size in bytes
145+
name n base64_string The path to a file
146+
status st base64_string Status messages
147+
parent pr safe_string The file id of the parent directory
148+
data d base64_bytes Binary data
149+
================= ======== ============== =======================================================================
150+
151+
Here:
152+
153+
Enum
154+
One from a permitted set of values, for example::
155+
156+
ac=file
157+
158+
safe_string
159+
A string consisting only of characters from the set ``[0-9a-zA-Z_:.,/!@#$%^&*()[]{}~`?"'\\|=+-]``
160+
161+
integer
162+
A base-10 number composed of the characters ``[0-9]`` with a possible
163+
leading ``-`` sign
164+
165+
base64_string
166+
A base64 encoded UTF-8 string using the standard base64 encoding
167+
168+
base64_bytes
169+
Binary data encoded using the standard base64 encoding

kitty/file_transmission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class FileTransmissionCommand:
266266
size: int = field(default=-1, metadata={'sname': 'sz'})
267267
name: str = field(default='', metadata={'base64': True, 'sname': 'n'})
268268
status: str = field(default='', metadata={'base64': True, 'sname': 'st'})
269-
parent: str = field(default='', metadata={'base64': True, 'sname': 'pr'})
269+
parent: str = field(default='', metadata={'sname': 'pr'})
270270
data: bytes = field(default=b'', repr=False, metadata={'sname': 'd'})
271271

272272
def __repr__(self) -> str:

0 commit comments

Comments
 (0)