Install
Install with PiG
pig install npm:pi-copy-codeInstall with Pi
pi install npm:pi-copy-codeReview before installing
Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./extensions/index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.1.1 (README.md). PiG does not review it.
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