Command reference
ed clipboard scratch
The scratch buffer is a floating text editor owned by Clipboard. It has line numbers, simple highlighting and explicit copy and save actions. Open it with Control+Option+Command+B, Open scratch buffer in Clipboard settings, Command+E on a text row in the clipboard popup, or Edit in scratch buffer in the history sheet's row menu. The commands below drive the same buffer from a terminal.
Nothing leaves the buffer until you ask. Loading an entry reads history without
changing it, and editing never touches the pasteboard. copy puts the text on
the pasteboard as plain text, where Clipboard records it like any other copy.
save writes UTF-8 to a path you name.
Commands
| Command | What it does |
|---|---|
ed clipboard scratch or show |
Print the buffer text; --info prints lines, characters and language; --json prints both |
ed clipboard scratch open |
Show the floating editor |
ed clipboard scratch set <text> |
Replace the buffer; --file <path> reads a regular UTF-8 file of up to 4 MB; --language <name> sets highlighting |
ed clipboard scratch load <index> |
Replace the buffer with a text entry, numbered as in ed clipboard ls |
ed clipboard scratch copy |
Copy the buffer to the pasteboard |
ed clipboard scratch save <path> |
Write the buffer as UTF-8; --force replaces an existing file |
ed clipboard scratch language <name> |
Choose auto, plain, log, json, shell, swift, javascript, python, markdown, yaml or sql |
ed clipboard scratch restore [on|off] |
Print or change whether the text is kept after relaunch |
ed clipboard scratch clear |
Preview emptying the buffer; --yes applies it |
Every command except show and restore without an argument accepts --json
and prints the buffer details without the text: language,
automaticLanguage, lines, characters, bytes, source,
restoresSession and updatedAt. show --json adds text. save --json
prints path and bytes.
--file refuses symbolic links, devices, pipes and anything that is not a
regular file, and reads at most 4 MB. save refuses to write through a
symbolic link, and without --force the file is created exclusively, so an
existing file is never replaced.
Edit a copied log
ed clipboard ls --category text --limit 3ed clipboard scratch load 1ed clipboard scratch show --infoed clipboard scratch opened clipboard scratch copyEdit the text in the window between open and copy, or replace it with
set. Command+Return copies and Command+S saves from the window.
Session restore
restore on is the default. The buffer is written to scratch.json in
Clipboard's data folder off the main thread, about half a second after an edit,
and when the window closes. Moving the caret alone does not write; the caret
position is saved with the next write or when the window closes. The text comes
back when the buffer is first used after Edith opens; nothing is read at
launch. restore off deletes that file and keeps the text in memory only. The
same setting is Keep scratch text after relaunch in Clipboard settings and
in the window's options menu. A damaged scratch.json is moved to
scratch-damaged.json and the buffer starts empty.
The buffer holds up to 4 MB. Highlighting stops above 400,000 UTF-16 code units and the text stays editable.
Exit codes
| Code | When |
|---|---|
| 0 | The command did what it says, including show on an empty buffer |
| 1 | copy or save on an empty buffer, a non-text entry, an unknown language, oversized text, a link or non-regular --file, or save onto an existing file without --force |
| 2 | A command line ArgumentParser cannot parse, or both <text> and --file |
| 3 | No clipboard entry with that number, or an unreadable --file |
| 4 | Clipboard is off, or the clipboard history is empty and you named a number |