home

posts

notes

rss

llm + Espanso: Clipboard Summaries

I recently wrote an Espanso trigger named :llm(⋯) that pipes the contents of my clipboard to Simon Willison’s llm CLI tool and expands the trigger to llm’s output in a custom Obsidian callout. This regex trigger expects a keyword (like summarise, simplify, or translate) between its parenthesis, and transforms this keyword to a prompt that summarises, simplifies, or translates whatever text I current have within my clipboard.

After frequent use of this trigger, I noticed that I mostly use :llm(summarise). To simplify my workflow, I decided to transfer summarisation to a dedicated :summary trigger so that I don’t have to rely on providing and capturing keywords using regex:

- trigger: ":summary"
replace: "> [!llm] _\"{{title}}\"_\n> {{summary}}"
vars:
- name: clipboard
type: clipboard
- name: summary
type: shell
params:
cmd: "echo $ESPANSO_CLIPBOARD | llm -m 'gpt-4o' -s
\ 'Summarise the provided text into a concise UK English paragraph.
\ Ensure the summary captures essential information.'"
- name: title
type: shell
params:
cmd: "echo $ESPANSO_SUMMARY | llm -m 'gpt-4o-mini' -s
\ 'Generate a short one-sentence title that accurately reflects
\ the main idea of the summary. Use UK English.'"