Script Kit Logo
Script Kit
by John Lindquist
Free TutorialsTipsCommunity ScriptsDocsDiscussBlog
Aldo Preciado
Scripts /

Aldo Preciado

Clipboard history with image preview

by Aldo Preciado

[2023-05-22 08:51:17.374] [warn]  ☠️ ERROR PROMPT SHOULD SHOW ☠️
[2023-05-22 08:51:17.393] [warn]  Error: ENOENT: no such file or directory, rename '/Users/aldo/.kenv/db/.clipboard-history.json.tmp' -> '/Users/aldo/.kenv/db/clipboard-history.json'
// Name: Clipboard history
// Author: Aldo Preciado
// GitHub: @aldirrix
// Shortcut: command shift v
import "@johnlindquist/kit";
const history = await getClipboardHistory();
let { value, type } = await arg("What to paste?", () => {
return history.map(({ value, type, timestamp, maybeSecret }) => {
const multilinePreview = value.includes("\n")
? `<div class="font-mono text-xs">${value
.split("\n")
.map((line) => `<p>${line}</p>`)
.join("")}<div>`
: null;
const preview = type === "image" ? `<img src="${value}" alt="${value}">` : multilinePreview;
return {
type,
name: maybeSecret ? value.slice(0, 2).padEnd(10, "*") : value,
value: {
value,
type,
},
description: timestamp,
preview,
};
});
});
if (type === "text") {
await setSelectedText(value);
}
if (type === "image") {
await copyPathAsImage(value);
await keystroke("command v");
}
created by
John Lindquist
GitHub