pi-copy-code0.1.1
Pi extension: press ctrl+y, then a letter, to copy a code block from the last response.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-copy-code
Press ctrl+y in Pi, then a letter. That code block from the last response is on your clipboard.
Try it
- Install:
pi install npm:pi-copy-code - Ask Pi for something with code blocks
- Press
ctrl+y:
╭──────────────────────────────────────────────────╮
│ Copy code block │
│ a bash npm install jsonwebtoken 1 line │
│ s ts export function verify(tok… 12 lines │
│ press a letter to copy · esc cancels │
╰──────────────────────────────────────────────────╯
- Press
s. A toast confirms:Copied ts block (12 lines)
Behavior
- One block: copies right away, no picker.
- Which response: only the last one: every assistant message since your last prompt, including text between tool calls. Inline
codeis not a block. If the last response has no fenced code blocks, you get "No code blocks in the last response". - Letters: home row first (
a s d f g h j k l, thenq w e …). Up to 26 blocks are offered. - Copied text: the block's contents without the fences. Fences indented inside list items have that indent removed.
- Clipboard: uses Pi's own clipboard helper, so it works wherever Pi's built-in copy works.
ctrl+y and the editor
Pi binds ctrl+y to "yank" (paste the last deleted text) in the input editor. This extension takes the key over, and Pi prints a shortcut-conflict warning at startup. To silence it, add this to ~/.pi/agent/keybindings.json:
{ "tui.editor.yank": [] }
Develop locally
pnpm install
pnpm test # node --test
pnpm typecheck # tsc
pnpm dev # start pi with this extension loaded from source