Read the image from clipboard, convert it to Markdown using a system prompt template, and copy the Markdown result while rendering it to the terminal with Glow.
After setting it up you can do it with a one-liner:
$ impaste | OPENROUTER_KEY=xxx llm --template md -a - | tee >(pbcopy) >(glow -) > /dev/null
First, install the simonw/llm utility with uv:
$ uv tool install --with llm-openrouter llmThen, we need this function to read the image in the system clipboard:
# Output the image data in clipboard to stdout.
# @example impaste > /tmp/image.png
# @see https://til.simonwillison.net/macos/impaste
function impaste {
if [[ "$OSTYPE" == darwin* ]]; then
# macOS: use osascript
tempfile=$(mktemp -t clipboard.XXXXXXXXXX.png)
osascript -e 'set theImage to the clipboard as «class PNGf»' \
-e "set theFile to open for access POSIX file \"$tempfile\" with write permission" \
-e 'write theImage to theFile' \
-e 'close access theFile'
cat "$tempfile"
rm "$tempfile"
elif command -v xclip &> /dev/null; then
# Linux with X11: use xclip
xclip -selection clipboard -t image/png -o
elif command -v wl-paste &> /dev/null; then
# Linux with Wayland: use wl-paste
wl-paste --type image/png
else
echo "Error: impaste requires osascript (macOS), xclip (X11), or wl-clipboard (Wayland)" >&2
return 1
fi
}Then put md.yaml to ~/.config/llm/templates/md.yaml. Depending on your API provider, a API key will be
required. I use OpenRouter.
After that install glow on your system to render Markdown in the Terminal.