Part 2: Clipboard special history, preview images as well

Open clipboard-history in Script Kit

// Menu: Clipboard History
// Description: Copy something from the clipboard history
// Shortcut: command shift v
import "@johnlindquist/kit"
let { history } = await db("clipboard-history")
let { value, type } = await arg("What to paste?", () => {
return history.map(({ value, type, timestamp, secret }) => {
return {
type,
name: secret ? value.slice(0, 4).padEnd(10, "*") : value,
value: {
value,
type,
},
description: timestamp,
preview:
type === "image"
? md(`![timestamp](${value})`)
: value.includes("\n")
? `<div class="font-mono text-xs">${value
.split("\n")
.map((line) => `<p>${line}</p>`)
.join("")}<div>`
: null,
}
})
})
if (type === "image") {
await copyPathAsImage(value)
await keystroke("command v")
}
if (type === "text") {
await setSelectedText(value)
}