kovidgoyal/kitty · warning
The clipboard is empty
Error message
The clipboard is empty
What it means
After querying the peer for the list of available MIME types (DATA ... DONE handshake), an empty list means the clipboard currently holds nothing. The kitten reports 'The clipboard is empty' rather than proceeding to per-output assignment.
Source
Thrown at kittens/clipboard/read.go:360
}
lp.OnEscapeCode = func(etype loop.EscapeCodeType, data []byte) (err error) {
metadata, payload, err := parse_escape_code(etype, data)
if err != nil {
return err
}
if metadata == nil {
return nil
}
if reading_available_mimes {
switch metadata["status"] {
case "DATA":
available_mimes = utils.Map(strings.TrimSpace, strings.Split(utils.UnsafeBytesToString(payload), " "))
case "OK":
case "DONE":
reading_available_mimes = false
if len(available_mimes) == 0 {
return fmt.Errorf("The clipboard is empty")
}
for _, o := range outputs {
err = o.assign_mime_type(available_mimes, aliases)
if err != nil {
return err
}
if o.remote_mime_type == "." {
o.started = true
o.add_data(utils.UnsafeStringToBytes(strings.Join(available_mimes, "\n")))
o.all_data_received = true
} else {
requested_mimes[o.remote_mime_type] = o
}
}
if len(requested_mimes) > 0 {
lp.QueueWriteString(encode(basic_metadata, strings.Join(utils.Keys(requested_mimes), " ")))
} else {
lp.Quit(0)View on GitHub (pinned to 6d5d0c4406)
Solutions
- Copy something first, then retry the get
- Verify which machine's clipboard you are reading (local vs remote over ssh) and copy there
- Add a retry/empty-check guard in scripts that poll the clipboard
Example fix
# before kitten clipboard get out.txt # nothing copied yet # after # copy text in the source app first, then: kitten clipboard get out.txt
Defensive patterns
Strategy: try-catch
Validate before calling
null
Try / catch
out=$(kitten clipboard get f 2>&1) || { echo "$out" | grep -q 'clipboard is empty' && exit 0; exit 1; } # treat empty as non-error Prevention
- Treat empty clipboard as an expected state in polling scripts
- Copy before reading; verify you target the right machine's clipboard
When it happens
Trigger: `kitten clipboard get`/`getfile` when nothing has ever been copied, or the clipboard was cleared; also when the remote peer reports an empty DATA list (e.g. clipboard cleared on the machine that would serve the data).
Common situations: Scripts running right after boot or clipboard-clear operations; reading a remote clipboard over ssh where the remote clipboard daemon has no content; racing with a clipboard manager that clears on focus loss.
Related errors
- Too much piped data
- Failed to read from STDIN pipe with error: %w
- Failed to create a temporary from STDIN pipe with error: %w
- Failed to copy data from STDIN pipe to temp file with error:
- Invalid base64 encoded data from terminal with error: %w
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/aad4b42bc88672e2.
Report an issue: GitHub.